home *** CD-ROM | disk | FTP | other *** search
Wrap
# Source Generated with Decompyle++ # File: in.pyc (Python 2.5) import _xapian import new new_instancemethod = new.instancemethod try: _swig_property = property except NameError: pass def _swig_setattr_nondynamic(self, class_type, name, value, static = 1): if name == 'thisown': return self.this.own(value) if name == 'this': if type(value).__name__ == 'PySwigObject': self.__dict__[name] = value return None method = class_type.__swig_setmethods__.get(name, None) if method: return method(self, value) if not static or hasattr(self, name): self.__dict__[name] = value else: raise AttributeError('You cannot add attributes to %s' % self) def _swig_setattr(self, class_type, name, value): return _swig_setattr_nondynamic(self, class_type, name, value, 0) def _swig_getattr(self, class_type, name): if name == 'thisown': return self.this.own() method = class_type.__swig_getmethods__.get(name, None) if method: return method(self) raise AttributeError, name def _swig_repr(self): try: strthis = 'proxy of ' + self.this.__repr__() except: strthis = '' return '<%s.%s; %s >' % (self.__class__.__module__, self.__class__.__name__, strthis) import types try: _object = types.ObjectType _newclass = 1 except AttributeError: class _object: pass _newclass = 0 del types def _swig_setattr_nondynamic_method(set): def set_attr(self, name, value): if name == 'thisown': return self.this.own(value) if hasattr(self, name) or name == 'this': set(self, name, value) else: raise AttributeError('You cannot add attributes to %s' % self) return set_attr try: import weakref weakref_proxy = weakref.proxy except: weakref_proxy = lambda x: x class PySwigIterator(object): thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') def __init__(self): raise AttributeError, 'No constructor defined' __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_PySwigIterator def __iter__(self): return self PySwigIterator.value = new_instancemethod(_xapian.PySwigIterator_value, None, PySwigIterator) PySwigIterator.incr = new_instancemethod(_xapian.PySwigIterator_incr, None, PySwigIterator) PySwigIterator.decr = new_instancemethod(_xapian.PySwigIterator_decr, None, PySwigIterator) PySwigIterator.distance = new_instancemethod(_xapian.PySwigIterator_distance, None, PySwigIterator) PySwigIterator.equal = new_instancemethod(_xapian.PySwigIterator_equal, None, PySwigIterator) PySwigIterator.copy = new_instancemethod(_xapian.PySwigIterator_copy, None, PySwigIterator) PySwigIterator.next = new_instancemethod(_xapian.PySwigIterator_next, None, PySwigIterator) PySwigIterator.previous = new_instancemethod(_xapian.PySwigIterator_previous, None, PySwigIterator) PySwigIterator.advance = new_instancemethod(_xapian.PySwigIterator_advance, None, PySwigIterator) PySwigIterator.__eq__ = new_instancemethod(_xapian.PySwigIterator___eq__, None, PySwigIterator) PySwigIterator.__ne__ = new_instancemethod(_xapian.PySwigIterator___ne__, None, PySwigIterator) PySwigIterator.__iadd__ = new_instancemethod(_xapian.PySwigIterator___iadd__, None, PySwigIterator) PySwigIterator.__isub__ = new_instancemethod(_xapian.PySwigIterator___isub__, None, PySwigIterator) PySwigIterator.__add__ = new_instancemethod(_xapian.PySwigIterator___add__, None, PySwigIterator) PySwigIterator.__sub__ = new_instancemethod(_xapian.PySwigIterator___sub__, None, PySwigIterator) PySwigIterator_swigregister = _xapian.PySwigIterator_swigregister PySwigIterator_swigregister(PySwigIterator) MSET_DID = _xapian.MSET_DID MSET_WT = _xapian.MSET_WT MSET_RANK = _xapian.MSET_RANK MSET_PERCENT = _xapian.MSET_PERCENT MSET_DOCUMENT = _xapian.MSET_DOCUMENT ESET_TNAME = _xapian.ESET_TNAME ESET_WT = _xapian.ESET_WT class Error(Exception): __swig_setmethods__ = { } __setattr__ = lambda self, name, value: _swig_setattr(self, Error, name, value) __swig_getmethods__ = { } __getattr__ = lambda self, name: _swig_getattr(self, Error, name) def __init__(self): raise AttributeError, 'No constructor defined' __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_Error Error.get_type = new_instancemethod(_xapian.Error_get_type, None, Error) Error.get_msg = new_instancemethod(_xapian.Error_get_msg, None, Error) Error.get_context = new_instancemethod(_xapian.Error_get_context, None, Error) Error.get_error_string = new_instancemethod(_xapian.Error_get_error_string, None, Error) Error.get_errno = new_instancemethod(_xapian.Error_get_errno, None, Error) Error.__str__ = new_instancemethod(_xapian.Error___str__, None, Error) Error_swigregister = _xapian.Error_swigregister Error_swigregister(Error) class LogicError(Error): __swig_setmethods__ = { } for _s in [ Error]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, LogicError, name, value) __swig_getmethods__ = { } for _s in [ Error]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, LogicError, name) def __init__(self): raise AttributeError, 'No constructor defined' __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_LogicError LogicError_swigregister = _xapian.LogicError_swigregister LogicError_swigregister(LogicError) class RuntimeError(Error): __swig_setmethods__ = { } for _s in [ Error]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, RuntimeError, name, value) __swig_getmethods__ = { } for _s in [ Error]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, RuntimeError, name) def __init__(self): raise AttributeError, 'No constructor defined' __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_RuntimeError RuntimeError_swigregister = _xapian.RuntimeError_swigregister RuntimeError_swigregister(RuntimeError) class AssertionError(LogicError): __swig_setmethods__ = { } for _s in [ LogicError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, AssertionError, name, value) __swig_getmethods__ = { } for _s in [ LogicError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, AssertionError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.AssertionError_swiginit(self, _xapian.new_AssertionError(*args)) __swig_destroy__ = _xapian.delete_AssertionError AssertionError_swigregister = _xapian.AssertionError_swigregister AssertionError_swigregister(AssertionError) class InvalidArgumentError(LogicError): __swig_setmethods__ = { } for _s in [ LogicError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, InvalidArgumentError, name, value) __swig_getmethods__ = { } for _s in [ LogicError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, InvalidArgumentError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.InvalidArgumentError_swiginit(self, _xapian.new_InvalidArgumentError(*args)) __swig_destroy__ = _xapian.delete_InvalidArgumentError InvalidArgumentError_swigregister = _xapian.InvalidArgumentError_swigregister InvalidArgumentError_swigregister(InvalidArgumentError) class InvalidOperationError(LogicError): __swig_setmethods__ = { } for _s in [ LogicError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, InvalidOperationError, name, value) __swig_getmethods__ = { } for _s in [ LogicError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, InvalidOperationError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.InvalidOperationError_swiginit(self, _xapian.new_InvalidOperationError(*args)) __swig_destroy__ = _xapian.delete_InvalidOperationError InvalidOperationError_swigregister = _xapian.InvalidOperationError_swigregister InvalidOperationError_swigregister(InvalidOperationError) class UnimplementedError(LogicError): __swig_setmethods__ = { } for _s in [ LogicError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, UnimplementedError, name, value) __swig_getmethods__ = { } for _s in [ LogicError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, UnimplementedError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.UnimplementedError_swiginit(self, _xapian.new_UnimplementedError(*args)) __swig_destroy__ = _xapian.delete_UnimplementedError UnimplementedError_swigregister = _xapian.UnimplementedError_swigregister UnimplementedError_swigregister(UnimplementedError) class DatabaseError(RuntimeError): __swig_setmethods__ = { } for _s in [ RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseError, name, value) __swig_getmethods__ = { } for _s in [ RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.DatabaseError_swiginit(self, _xapian.new_DatabaseError(*args)) __swig_destroy__ = _xapian.delete_DatabaseError DatabaseError_swigregister = _xapian.DatabaseError_swigregister DatabaseError_swigregister(DatabaseError) class DatabaseCorruptError(DatabaseError): __swig_setmethods__ = { } for _s in [ DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCorruptError, name, value) __swig_getmethods__ = { } for _s in [ DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseCorruptError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.DatabaseCorruptError_swiginit(self, _xapian.new_DatabaseCorruptError(*args)) __swig_destroy__ = _xapian.delete_DatabaseCorruptError DatabaseCorruptError_swigregister = _xapian.DatabaseCorruptError_swigregister DatabaseCorruptError_swigregister(DatabaseCorruptError) class DatabaseCreateError(DatabaseError): __swig_setmethods__ = { } for _s in [ DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCreateError, name, value) __swig_getmethods__ = { } for _s in [ DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseCreateError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.DatabaseCreateError_swiginit(self, _xapian.new_DatabaseCreateError(*args)) __swig_destroy__ = _xapian.delete_DatabaseCreateError DatabaseCreateError_swigregister = _xapian.DatabaseCreateError_swigregister DatabaseCreateError_swigregister(DatabaseCreateError) class DatabaseLockError(DatabaseError): __swig_setmethods__ = { } for _s in [ DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseLockError, name, value) __swig_getmethods__ = { } for _s in [ DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseLockError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.DatabaseLockError_swiginit(self, _xapian.new_DatabaseLockError(*args)) __swig_destroy__ = _xapian.delete_DatabaseLockError DatabaseLockError_swigregister = _xapian.DatabaseLockError_swigregister DatabaseLockError_swigregister(DatabaseLockError) class DatabaseModifiedError(DatabaseError): __swig_setmethods__ = { } for _s in [ DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseModifiedError, name, value) __swig_getmethods__ = { } for _s in [ DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseModifiedError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.DatabaseModifiedError_swiginit(self, _xapian.new_DatabaseModifiedError(*args)) __swig_destroy__ = _xapian.delete_DatabaseModifiedError DatabaseModifiedError_swigregister = _xapian.DatabaseModifiedError_swigregister DatabaseModifiedError_swigregister(DatabaseModifiedError) class DatabaseOpeningError(DatabaseError): __swig_setmethods__ = { } for _s in [ DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseOpeningError, name, value) __swig_getmethods__ = { } for _s in [ DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseOpeningError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.DatabaseOpeningError_swiginit(self, _xapian.new_DatabaseOpeningError(*args)) __swig_destroy__ = _xapian.delete_DatabaseOpeningError DatabaseOpeningError_swigregister = _xapian.DatabaseOpeningError_swigregister DatabaseOpeningError_swigregister(DatabaseOpeningError) class DatabaseVersionError(DatabaseOpeningError): __swig_setmethods__ = { } for _s in [ DatabaseOpeningError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseVersionError, name, value) __swig_getmethods__ = { } for _s in [ DatabaseOpeningError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseVersionError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.DatabaseVersionError_swiginit(self, _xapian.new_DatabaseVersionError(*args)) __swig_destroy__ = _xapian.delete_DatabaseVersionError DatabaseVersionError_swigregister = _xapian.DatabaseVersionError_swigregister DatabaseVersionError_swigregister(DatabaseVersionError) class DocNotFoundError(RuntimeError): __swig_setmethods__ = { } for _s in [ RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, DocNotFoundError, name, value) __swig_getmethods__ = { } for _s in [ RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, DocNotFoundError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.DocNotFoundError_swiginit(self, _xapian.new_DocNotFoundError(*args)) __swig_destroy__ = _xapian.delete_DocNotFoundError DocNotFoundError_swigregister = _xapian.DocNotFoundError_swigregister DocNotFoundError_swigregister(DocNotFoundError) class FeatureUnavailableError(RuntimeError): __swig_setmethods__ = { } for _s in [ RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, FeatureUnavailableError, name, value) __swig_getmethods__ = { } for _s in [ RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, FeatureUnavailableError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.FeatureUnavailableError_swiginit(self, _xapian.new_FeatureUnavailableError(*args)) __swig_destroy__ = _xapian.delete_FeatureUnavailableError FeatureUnavailableError_swigregister = _xapian.FeatureUnavailableError_swigregister FeatureUnavailableError_swigregister(FeatureUnavailableError) class InternalError(RuntimeError): __swig_setmethods__ = { } for _s in [ RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, InternalError, name, value) __swig_getmethods__ = { } for _s in [ RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, InternalError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.InternalError_swiginit(self, _xapian.new_InternalError(*args)) __swig_destroy__ = _xapian.delete_InternalError InternalError_swigregister = _xapian.InternalError_swigregister InternalError_swigregister(InternalError) class NetworkError(RuntimeError): __swig_setmethods__ = { } for _s in [ RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, NetworkError, name, value) __swig_getmethods__ = { } for _s in [ RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, NetworkError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.NetworkError_swiginit(self, _xapian.new_NetworkError(*args)) __swig_destroy__ = _xapian.delete_NetworkError NetworkError_swigregister = _xapian.NetworkError_swigregister NetworkError_swigregister(NetworkError) class NetworkTimeoutError(NetworkError): __swig_setmethods__ = { } for _s in [ NetworkError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, NetworkTimeoutError, name, value) __swig_getmethods__ = { } for _s in [ NetworkError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, NetworkTimeoutError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.NetworkTimeoutError_swiginit(self, _xapian.new_NetworkTimeoutError(*args)) __swig_destroy__ = _xapian.delete_NetworkTimeoutError NetworkTimeoutError_swigregister = _xapian.NetworkTimeoutError_swigregister NetworkTimeoutError_swigregister(NetworkTimeoutError) class QueryParserError(RuntimeError): __swig_setmethods__ = { } for _s in [ RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, QueryParserError, name, value) __swig_getmethods__ = { } for _s in [ RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, QueryParserError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.QueryParserError_swiginit(self, _xapian.new_QueryParserError(*args)) __swig_destroy__ = _xapian.delete_QueryParserError QueryParserError_swigregister = _xapian.QueryParserError_swigregister QueryParserError_swigregister(QueryParserError) class RangeError(RuntimeError): __swig_setmethods__ = { } for _s in [ RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', { })) __setattr__ = lambda self, name, value: _swig_setattr(self, RangeError, name, value) __swig_getmethods__ = { } for _s in [ RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', { })) __getattr__ = lambda self, name: _swig_getattr(self, RangeError, name) __repr__ = _swig_repr def __init__(self, *args): _xapian.RangeError_swiginit(self, _xapian.new_RangeError(*args)) __swig_destroy__ = _xapian.delete_RangeError RangeError_swigregister = _xapian.RangeError_swigregister RangeError_swigregister(RangeError) version_string = _xapian.version_string major_version = _xapian.major_version minor_version = _xapian.minor_version revision = _xapian.revision xapian_version_string = _xapian.xapian_version_string xapian_major_version = _xapian.xapian_major_version xapian_minor_version = _xapian.xapian_minor_version xapian_revision = _xapian.xapian_revision class PositionIterator(object): ''' An iterator pointing to items in a list of positions. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Copying is allowed. Xapian::PositionIterator::PositionIterator(const PositionIterator &o) The internals are reference counted, so copying is also cheap. ''' _xapian.PositionIterator_swiginit(self, _xapian.new_PositionIterator(*args)) __swig_destroy__ = _xapian.delete_PositionIterator def skip_to(*args): ''' void Xapian::PositionIterator::skip_to(Xapian::termpos pos) ''' return _xapian.PositionIterator_skip_to(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::PositionIterator::get_description() const ''' return _xapian.PositionIterator___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::PositionIterator::get_description() const ''' return _xapian.PositionIterator_get_description(*args) PositionIterator.get_termpos = new_instancemethod(_xapian.PositionIterator_get_termpos, None, PositionIterator) PositionIterator.next = new_instancemethod(_xapian.PositionIterator_next, None, PositionIterator) PositionIterator.equals = new_instancemethod(_xapian.PositionIterator_equals, None, PositionIterator) PositionIterator.skip_to = new_instancemethod(_xapian.PositionIterator_skip_to, None, PositionIterator) PositionIterator.__str__ = new_instancemethod(_xapian.PositionIterator___str__, None, PositionIterator) PositionIterator.get_description = new_instancemethod(_xapian.PositionIterator_get_description, None, PositionIterator) PositionIterator.__eq__ = new_instancemethod(_xapian.PositionIterator___eq__, None, PositionIterator) PositionIterator.__ne__ = new_instancemethod(_xapian.PositionIterator___ne__, None, PositionIterator) PositionIterator_swigregister = _xapian.PositionIterator_swigregister PositionIterator_swigregister(PositionIterator) cvar = _xapian.cvar BAD_VALUENO = cvar.BAD_VALUENO class PostingIterator(object): ''' An iterator pointing to items in a list of postings. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_PostingIterator def __init__(self, *args): ''' Copying is allowed. Xapian::PostingIterator::PostingIterator(const PostingIterator &other) The internals are reference counted, so copying is also cheap. ''' _xapian.PostingIterator_swiginit(self, _xapian.new_PostingIterator(*args)) def skip_to(*args): """ Skip the iterator to document did, or the first document after did if did isn't in the list of documents being iterated. void Xapian::PostingIterator::skip_to(Xapian::docid did) """ return _xapian.PostingIterator_skip_to(*args) def get_doclength(*args): ''' Get the length of the document at the current position in the postlist. Xapian::doclength Xapian::PostingIterator::get_doclength() const This information may be stored in the postlist, in which case this lookup should be extremely fast (indeed, not require further disk access). If the information is not present in the postlist, it will be retrieved from the database, at a greater performance cost. ''' return _xapian.PostingIterator_get_doclength(*args) def get_wdf(*args): ''' Get the within document frequency of the document at the current position in the postlist. Xapian::termcount Xapian::PostingIterator::get_wdf() const ''' return _xapian.PostingIterator_get_wdf(*args) def positionlist_begin(*args): ''' Return PositionIterator pointing to start of positionlist for current document. PositionIterator Xapian::PostingIterator::positionlist_begin() const ''' return _xapian.PostingIterator_positionlist_begin(*args) def positionlist_end(*args): ''' Return PositionIterator pointing to end of positionlist for current document. PositionIterator Xapian::PostingIterator::positionlist_end() const ''' return _xapian.PostingIterator_positionlist_end(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::PostingIterator::get_description() const ''' return _xapian.PostingIterator___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::PostingIterator::get_description() const ''' return _xapian.PostingIterator_get_description(*args) PostingIterator.skip_to = new_instancemethod(_xapian.PostingIterator_skip_to, None, PostingIterator) PostingIterator.get_doclength = new_instancemethod(_xapian.PostingIterator_get_doclength, None, PostingIterator) PostingIterator.get_wdf = new_instancemethod(_xapian.PostingIterator_get_wdf, None, PostingIterator) PostingIterator.positionlist_begin = new_instancemethod(_xapian.PostingIterator_positionlist_begin, None, PostingIterator) PostingIterator.positionlist_end = new_instancemethod(_xapian.PostingIterator_positionlist_end, None, PostingIterator) PostingIterator.__str__ = new_instancemethod(_xapian.PostingIterator___str__, None, PostingIterator) PostingIterator.get_description = new_instancemethod(_xapian.PostingIterator_get_description, None, PostingIterator) PostingIterator.__eq__ = new_instancemethod(_xapian.PostingIterator___eq__, None, PostingIterator) PostingIterator.__ne__ = new_instancemethod(_xapian.PostingIterator___ne__, None, PostingIterator) PostingIterator.get_docid = new_instancemethod(_xapian.PostingIterator_get_docid, None, PostingIterator) PostingIterator.next = new_instancemethod(_xapian.PostingIterator_next, None, PostingIterator) PostingIterator.equals = new_instancemethod(_xapian.PostingIterator_equals, None, PostingIterator) PostingIterator_swigregister = _xapian.PostingIterator_swigregister PostingIterator_swigregister(PostingIterator) __eq__ = _xapian.__eq__ __ne__ = _xapian.__ne__ class TermIterator(object): ''' An iterator pointing to items in a list of terms. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Copying is allowed. Xapian::TermIterator::TermIterator(const TermIterator &other) The internals are reference counted, so copying is also cheap. ''' _xapian.TermIterator_swiginit(self, _xapian.new_TermIterator(*args)) __swig_destroy__ = _xapian.delete_TermIterator def skip_to(*args): """ Skip the iterator to term tname, or the first term after tname if tname isn't in the list of terms being iterated. void Xapian::TermIterator::skip_to(const std::string &tname) """ return _xapian.TermIterator_skip_to(*args) def get_wdf(*args): ''' Return the wdf of the current term (if meaningful). Xapian::termcount Xapian::TermIterator::get_wdf() const The wdf (within document frequency) is the number of occurences of a term in a particular document. ''' return _xapian.TermIterator_get_wdf(*args) def get_termfreq(*args): ''' Return the term frequency of the current term (if meaningful). Xapian::doccount Xapian::TermIterator::get_termfreq() const The term frequency is the number of documents which a term indexes. ''' return _xapian.TermIterator_get_termfreq(*args) def positionlist_begin(*args): ''' Return PositionIterator pointing to start of positionlist for current term. PositionIterator Xapian::TermIterator::positionlist_begin() const ''' return _xapian.TermIterator_positionlist_begin(*args) def positionlist_end(*args): ''' Return PositionIterator pointing to end of positionlist for current term. PositionIterator Xapian::TermIterator::positionlist_end() const ''' return _xapian.TermIterator_positionlist_end(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::TermIterator::get_description() const ''' return _xapian.TermIterator___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::TermIterator::get_description() const ''' return _xapian.TermIterator_get_description(*args) TermIterator.get_term = new_instancemethod(_xapian.TermIterator_get_term, None, TermIterator) TermIterator.next = new_instancemethod(_xapian.TermIterator_next, None, TermIterator) TermIterator.equals = new_instancemethod(_xapian.TermIterator_equals, None, TermIterator) TermIterator.skip_to = new_instancemethod(_xapian.TermIterator_skip_to, None, TermIterator) TermIterator.get_wdf = new_instancemethod(_xapian.TermIterator_get_wdf, None, TermIterator) TermIterator.get_termfreq = new_instancemethod(_xapian.TermIterator_get_termfreq, None, TermIterator) TermIterator.positionlist_begin = new_instancemethod(_xapian.TermIterator_positionlist_begin, None, TermIterator) TermIterator.positionlist_end = new_instancemethod(_xapian.TermIterator_positionlist_end, None, TermIterator) TermIterator.__str__ = new_instancemethod(_xapian.TermIterator___str__, None, TermIterator) TermIterator.get_description = new_instancemethod(_xapian.TermIterator_get_description, None, TermIterator) TermIterator.__eq__ = new_instancemethod(_xapian.TermIterator___eq__, None, TermIterator) TermIterator.__ne__ = new_instancemethod(_xapian.TermIterator___ne__, None, TermIterator) TermIterator_swigregister = _xapian.TermIterator_swigregister TermIterator_swigregister(TermIterator) class ValueIterator(object): ''' An iterator pointing to values associated with a document. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Copying is allowed (and is cheap). Xapian::ValueIterator::ValueIterator(const ValueIterator &other) ''' _xapian.ValueIterator_swiginit(self, _xapian.new_ValueIterator(*args)) __swig_destroy__ = _xapian.delete_ValueIterator def get_valueno(*args): ''' Get the number of the value at the current position. Xapian::valueno Xapian::ValueIterator::get_valueno() const ''' return _xapian.ValueIterator_get_valueno(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::ValueIterator::get_description() const ''' return _xapian.ValueIterator___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::ValueIterator::get_description() const ''' return _xapian.ValueIterator_get_description(*args) ValueIterator.get_value = new_instancemethod(_xapian.ValueIterator_get_value, None, ValueIterator) ValueIterator.next = new_instancemethod(_xapian.ValueIterator_next, None, ValueIterator) ValueIterator.equals = new_instancemethod(_xapian.ValueIterator_equals, None, ValueIterator) ValueIterator.get_valueno = new_instancemethod(_xapian.ValueIterator_get_valueno, None, ValueIterator) ValueIterator.__str__ = new_instancemethod(_xapian.ValueIterator___str__, None, ValueIterator) ValueIterator.get_description = new_instancemethod(_xapian.ValueIterator_get_description, None, ValueIterator) ValueIterator.__eq__ = new_instancemethod(_xapian.ValueIterator___eq__, None, ValueIterator) ValueIterator.__ne__ = new_instancemethod(_xapian.ValueIterator___ne__, None, ValueIterator) ValueIterator_swigregister = _xapian.ValueIterator_swigregister ValueIterator_swigregister(ValueIterator) class Document(object): ''' A document in the database - holds data, values, terms, and postings. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Make a new empty Document. Xapian::Document::Document() ''' _xapian.Document_swiginit(self, _xapian.new_Document(*args)) __swig_destroy__ = _xapian.delete_Document def get_value(*args): ''' Get value by number. std::string Xapian::Document::get_value(Xapian::valueno valueno) const Returns an empty string if no value with the given number is present in the document. Parameters: ----------- valueno: The number of the value. ''' return _xapian.Document_get_value(*args) def add_value(*args): ''' Add a new value. void Xapian::Document::add_value(Xapian::valueno valueno, const std::string &value) It will replace any existing value with the same number. ''' return _xapian.Document_add_value(*args) def remove_value(*args): ''' Remove any value with the given number. void Xapian::Document::remove_value(Xapian::valueno valueno) ''' return _xapian.Document_remove_value(*args) def clear_values(*args): ''' Remove all values associated with the document. void Xapian::Document::clear_values() ''' return _xapian.Document_clear_values(*args) def get_data(*args): """ Get data stored in the document. std::string Xapian::Document::get_data() const This is a potentially expensive operation, and shouldn't normally be used in a match decider functor. Put data for use by match deciders in a value instead. """ return _xapian.Document_get_data(*args) def set_data(*args): ''' Set data stored in the document. void Xapian::Document::set_data(const std::string &data) ''' return _xapian.Document_set_data(*args) def add_posting(*args): ''' Add an occurrence of a term at a particular position. void Xapian::Document::add_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfinc=1) Multiple occurrences of the term at the same position are represented only once in the positional information, but do increase the wdf. If the term is not already in the document, it will be added to it. Parameters: ----------- tname: The name of the term. tpos: The position of the term. wdfinc: The increment that will be applied to the wdf for this term. ''' return _xapian.Document_add_posting(*args) def add_term(*args): ''' Add a term to the document, without positional information. void Xapian::Document::add_term(const std::string &tname, Xapian::termcount wdfinc=1) Any existing positional information for the term will be left unmodified. Parameters: ----------- tname: The name of the term. wdfinc: The increment that will be applied to the wdf for this term. ''' return _xapian.Document_add_term(*args) def remove_posting(*args): ''' Remove a posting of a term from the document. void Xapian::Document::remove_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfdec=1) Note that the term will still index the document even if all occurrences are removed. To remove a term from a document completely, use remove_term(). Parameters: ----------- tname: The name of the term. tpos: The position of the term. wdfdec: The decrement that will be applied to the wdf when removing this posting. The wdf will not go below the value of 0. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if the term is not at the position specified in the position list for this term in this document. Xapian::InvalidArgumentError: will be thrown if the term is not in the document ''' return _xapian.Document_remove_posting(*args) def remove_term(*args): ''' Remove a term and all postings associated with it. void Xapian::Document::remove_term(const std::string &tname) Parameters: ----------- tname: The name of the term. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if the term is not in the document ''' return _xapian.Document_remove_term(*args) def clear_terms(*args): ''' Remove all terms (and postings) from the document. void Xapian::Document::clear_terms() ''' return _xapian.Document_clear_terms(*args) def termlist_count(*args): ''' The length of the termlist - i.e. Xapian::termcount Xapian::Document::termlist_count() const the number of different terms which index this document. ''' return _xapian.Document_termlist_count(*args) def termlist_begin(*args): ''' Iterator for the terms in this document. TermIterator Xapian::Document::termlist_begin() const ''' return _xapian.Document_termlist_begin(*args) def termlist_end(*args): ''' Equivalent end iterator for termlist_begin(). TermIterator Xapian::Document::termlist_end() const ''' return _xapian.Document_termlist_end(*args) def values_count(*args): ''' Count the values in this document. Xapian::termcount Xapian::Document::values_count() const ''' return _xapian.Document_values_count(*args) def values_begin(*args): ''' Iterator for the values in this document. ValueIterator Xapian::Document::values_begin() const ''' return _xapian.Document_values_begin(*args) def values_end(*args): ''' Equivalent end iterator for values_begin(). ValueIterator Xapian::Document::values_end() const ''' return _xapian.Document_values_end(*args) def get_docid(*args): ''' Get the document id which is associated with this document (if any). docid Xapian::Document::get_docid() const NB If multiple databases are being searched together, then this will be the document id in the individual database, not the merged database! If this document came from a database, return the document id in that database. Otherwise, return 0. ''' return _xapian.Document_get_docid(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::Document::get_description() const ''' return _xapian.Document___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::Document::get_description() const ''' return _xapian.Document_get_description(*args) Document.get_value = new_instancemethod(_xapian.Document_get_value, None, Document) Document.add_value = new_instancemethod(_xapian.Document_add_value, None, Document) Document.remove_value = new_instancemethod(_xapian.Document_remove_value, None, Document) Document.clear_values = new_instancemethod(_xapian.Document_clear_values, None, Document) Document.get_data = new_instancemethod(_xapian.Document_get_data, None, Document) Document.set_data = new_instancemethod(_xapian.Document_set_data, None, Document) Document.add_posting = new_instancemethod(_xapian.Document_add_posting, None, Document) Document.add_term = new_instancemethod(_xapian.Document_add_term, None, Document) Document.remove_posting = new_instancemethod(_xapian.Document_remove_posting, None, Document) Document.remove_term = new_instancemethod(_xapian.Document_remove_term, None, Document) Document.clear_terms = new_instancemethod(_xapian.Document_clear_terms, None, Document) Document.termlist_count = new_instancemethod(_xapian.Document_termlist_count, None, Document) Document.termlist_begin = new_instancemethod(_xapian.Document_termlist_begin, None, Document) Document.termlist_end = new_instancemethod(_xapian.Document_termlist_end, None, Document) Document.values_count = new_instancemethod(_xapian.Document_values_count, None, Document) Document.values_begin = new_instancemethod(_xapian.Document_values_begin, None, Document) Document.values_end = new_instancemethod(_xapian.Document_values_end, None, Document) Document.get_docid = new_instancemethod(_xapian.Document_get_docid, None, Document) Document.__str__ = new_instancemethod(_xapian.Document___str__, None, Document) Document.get_description = new_instancemethod(_xapian.Document_get_description, None, Document) Document_swigregister = _xapian.Document_swigregister Document_swigregister(Document) class MSet(object): ''' A match set ( MSet). This class represents (a portion of) the results of a query. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Copying is allowed (and is cheap). Xapian::MSet::MSet(const MSet &other) ''' _xapian.MSet_swiginit(self, _xapian.new_MSet(*args)) __swig_destroy__ = _xapian.delete_MSet def fetch(*args): ''' Fetch all the items in the MSet. void Xapian::MSet::fetch() const ''' return _xapian.MSet_fetch(*args) def convert_to_percent(*args): ''' Return the percentage score for a particular item. Xapian::percent Xapian::MSet::convert_to_percent(const MSetIterator &it) const ''' return _xapian.MSet_convert_to_percent(*args) def get_termfreq(*args): ''' Return the term frequency of the given query term. Xapian::doccount Xapian::MSet::get_termfreq(const std::string &tname) const Parameters: ----------- tname: The term to look for. Parameters: ----------- Xapian::InvalidArgumentError: is thrown if the term was not in the query. ''' return _xapian.MSet_get_termfreq(*args) def get_termweight(*args): ''' Return the term weight of the given query term. Xapian::weight Xapian::MSet::get_termweight(const std::string &tname) const Parameters: ----------- tname: The term to look for. Parameters: ----------- Xapian::InvalidArgumentError: is thrown if the term was not in the query. ''' return _xapian.MSet_get_termweight(*args) def get_firstitem(*args): ''' The index of the first item in the result which was put into the MSet. Xapian::doccount Xapian::MSet::get_firstitem() const This corresponds to the parameter "first" specified in Xapian::Enquire::get_mset(). A value of 0 corresponds to the highest result being the first item in the MSet. ''' return _xapian.MSet_get_firstitem(*args) def get_matches_lower_bound(*args): ''' A lower bound on the number of documents in the database which match the query. Xapian::doccount Xapian::MSet::get_matches_lower_bound() const This figure takes into account collapsing of duplicates, and weighting cutoff values. This number is usually considerably less than the actual number of documents which match the query. ''' return _xapian.MSet_get_matches_lower_bound(*args) def get_matches_estimated(*args): ''' An estimate for the number of documents in the database which match the query. Xapian::doccount Xapian::MSet::get_matches_estimated() const This figure takes into account collapsing of duplicates, and weighting cutoff values. This value is returned because there is sometimes a request to display such information. However, our experience is that presenting this value to users causes them to worry about the large number of results, rather than how useful those at the top of the result set are, and is thus undesirable. ''' return _xapian.MSet_get_matches_estimated(*args) def get_matches_upper_bound(*args): ''' An upper bound on the number of documents in the database which match the query. Xapian::doccount Xapian::MSet::get_matches_upper_bound() const This figure takes into account collapsing of duplicates, and weighting cutoff values. This number is usually considerably greater than the actual number of documents which match the query. ''' return _xapian.MSet_get_matches_upper_bound(*args) def get_max_possible(*args): ''' The maximum possible weight in the MSet. Xapian::weight Xapian::MSet::get_max_possible() const This weight is likely not to be attained in the set of results, but represents an upper bound on the weight which a document could attain for the given query. ''' return _xapian.MSet_get_max_possible(*args) def get_max_attained(*args): ''' The greatest weight which is attained by any document in the database. Xapian::weight Xapian::MSet::get_max_attained() const If firstitem == 0, this is the weight of the first entry in items. If no documents are found by the query, this will be 0. Note that calculation of max_attained requires calculation of at least one result item - therefore, if no items were requested when the query was performed (by specifying maxitems = 0 in Xapian::Enquire::get_mset()), this value will be 0. ''' return _xapian.MSet_get_max_attained(*args) def size(*args): ''' The number of items in this MSet. Xapian::doccount Xapian::MSet::size() const ''' return _xapian.MSet_size(*args) def empty(*args): ''' Test if this MSet is empty. bool Xapian::MSet::empty() const ''' return _xapian.MSet_empty(*args) def begin(*args): ''' Iterator for the terms in this MSet. MSetIterator Xapian::MSet::begin() const ''' return _xapian.MSet_begin(*args) def end(*args): ''' End iterator corresponding to begin(). MSetIterator Xapian::MSet::end() const ''' return _xapian.MSet_end(*args) def back(*args): ''' Iterator pointing to the last element of this MSet. MSetIterator Xapian::MSet::back() const ''' return _xapian.MSet_back(*args) def get_hit(*args): ''' Get an item from the MSet. The supplied index is relative to the start of the MSet, not the absolute rank of the item. ''' return _xapian.MSet_get_hit(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::MSet::get_description() const ''' return _xapian.MSet___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::MSet::get_description() const ''' return _xapian.MSet_get_description(*args) items = _swig_property(_xapian.MSet_items_get) MSet.fetch = new_instancemethod(_xapian.MSet_fetch, None, MSet) MSet.convert_to_percent = new_instancemethod(_xapian.MSet_convert_to_percent, None, MSet) MSet.get_termfreq = new_instancemethod(_xapian.MSet_get_termfreq, None, MSet) MSet.get_termweight = new_instancemethod(_xapian.MSet_get_termweight, None, MSet) MSet.get_firstitem = new_instancemethod(_xapian.MSet_get_firstitem, None, MSet) MSet.get_matches_lower_bound = new_instancemethod(_xapian.MSet_get_matches_lower_bound, None, MSet) MSet.get_matches_estimated = new_instancemethod(_xapian.MSet_get_matches_estimated, None, MSet) MSet.get_matches_upper_bound = new_instancemethod(_xapian.MSet_get_matches_upper_bound, None, MSet) MSet.get_max_possible = new_instancemethod(_xapian.MSet_get_max_possible, None, MSet) MSet.get_max_attained = new_instancemethod(_xapian.MSet_get_max_attained, None, MSet) MSet.size = new_instancemethod(_xapian.MSet_size, None, MSet) MSet.empty = new_instancemethod(_xapian.MSet_empty, None, MSet) MSet.begin = new_instancemethod(_xapian.MSet_begin, None, MSet) MSet.end = new_instancemethod(_xapian.MSet_end, None, MSet) MSet.back = new_instancemethod(_xapian.MSet_back, None, MSet) MSet.get_hit = new_instancemethod(_xapian.MSet_get_hit, None, MSet) MSet.get_document_percentage = new_instancemethod(_xapian.MSet_get_document_percentage, None, MSet) MSet.get_document = new_instancemethod(_xapian.MSet_get_document, None, MSet) MSet.get_docid = new_instancemethod(_xapian.MSet_get_docid, None, MSet) MSet.get_document_id = new_instancemethod(_xapian.MSet_get_document_id, None, MSet) MSet.__str__ = new_instancemethod(_xapian.MSet___str__, None, MSet) MSet.get_description = new_instancemethod(_xapian.MSet_get_description, None, MSet) MSet.__cmp__ = new_instancemethod(_xapian.MSet___cmp__, None, MSet) MSet_swigregister = _xapian.MSet_swigregister MSet_swigregister(MSet) class MSetIterator(object): ''' An iterator pointing to items in an MSet. This is used for access to individual results of a match. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Copying is allowed (and is cheap). Xapian::MSetIterator::MSetIterator(const MSetIterator &other) ''' _xapian.MSetIterator_swiginit(self, _xapian.new_MSetIterator(*args)) __swig_destroy__ = _xapian.delete_MSetIterator def get_document(*args): ''' Get a Xapian::Document object for the current position. Xapian::Document Xapian::MSetIterator::get_document() const This method returns a Xapian::Document object which provides the information about the document pointed to by the MSetIterator. If the underlying database has suitable support, using this call (rather than asking the database for a document based on its document ID) will enable the system to ensure that the correct data is returned, and that the document has not been deleted or changed since the query was performed. A Xapian::Document object containing the document data. Parameters: ----------- Xapian::DocNotFoundError: The document specified could not be found in the database. ''' return _xapian.MSetIterator_get_document(*args) def get_rank(*args): ''' Get the rank of the document at the current position. Xapian::doccount Xapian::MSetIterator::get_rank() const The rank is the position that this document is at in the ordered list of results of the query. The result is 0-based - i.e. the top-ranked document has a rank of 0. ''' return _xapian.MSetIterator_get_rank(*args) def get_weight(*args): ''' Get the weight of the document at the current position. Xapian::weight Xapian::MSetIterator::get_weight() const ''' return _xapian.MSetIterator_get_weight(*args) def get_collapse_key(*args): ''' Get the collapse key for this document. std::string Xapian::MSetIterator::get_collapse_key() const ''' return _xapian.MSetIterator_get_collapse_key(*args) def get_collapse_count(*args): ''' Get an estimate of the number of documents that have been collapsed into this one. Xapian::doccount Xapian::MSetIterator::get_collapse_count() const The estimate will always be less than or equal to the actual number of other documents satisfying the match criteria with the same collapse key as this document. This method may return 0 even though there are other documents with the same collapse key which satisfying the match criteria. However if this method returns non-zero, there definitely are other such documents. So this method may be used to inform the user that there are "at least N other matches in this group", or to control whether to offer a "show other documents in this group" feature (but note that it may not offer it in every case where it would show other documents). ''' return _xapian.MSetIterator_get_collapse_count(*args) def get_percent(*args): ''' This returns the weight of the document as a percentage score. Xapian::percent Xapian::MSetIterator::get_percent() const The return value will be in the range 0 to 100: 0 meaning that the item did not match the query at all. ''' return _xapian.MSetIterator_get_percent(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::MSetIterator::get_description() const ''' return _xapian.MSetIterator___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::MSetIterator::get_description() const ''' return _xapian.MSetIterator_get_description(*args) MSetIterator.get_docid = new_instancemethod(_xapian.MSetIterator_get_docid, None, MSetIterator) MSetIterator.next = new_instancemethod(_xapian.MSetIterator_next, None, MSetIterator) MSetIterator.prev = new_instancemethod(_xapian.MSetIterator_prev, None, MSetIterator) MSetIterator.equals = new_instancemethod(_xapian.MSetIterator_equals, None, MSetIterator) MSetIterator.get_document = new_instancemethod(_xapian.MSetIterator_get_document, None, MSetIterator) MSetIterator.get_rank = new_instancemethod(_xapian.MSetIterator_get_rank, None, MSetIterator) MSetIterator.get_weight = new_instancemethod(_xapian.MSetIterator_get_weight, None, MSetIterator) MSetIterator.get_collapse_key = new_instancemethod(_xapian.MSetIterator_get_collapse_key, None, MSetIterator) MSetIterator.get_collapse_count = new_instancemethod(_xapian.MSetIterator_get_collapse_count, None, MSetIterator) MSetIterator.get_percent = new_instancemethod(_xapian.MSetIterator_get_percent, None, MSetIterator) MSetIterator.__str__ = new_instancemethod(_xapian.MSetIterator___str__, None, MSetIterator) MSetIterator.get_description = new_instancemethod(_xapian.MSetIterator_get_description, None, MSetIterator) MSetIterator.__eq__ = new_instancemethod(_xapian.MSetIterator___eq__, None, MSetIterator) MSetIterator.__ne__ = new_instancemethod(_xapian.MSetIterator___ne__, None, MSetIterator) MSetIterator_swigregister = _xapian.MSetIterator_swigregister MSetIterator_swigregister(MSetIterator) class ESet(object): ''' Class representing an ordered set of expand terms (an ESet). This set represents the results of an expand operation, which is performed by Xapian::Enquire::get_eset(). ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Copying is allowed (and is cheap). Xapian::ESet::ESet(const ESet &other) ''' _xapian.ESet_swiginit(self, _xapian.new_ESet(*args)) __swig_destroy__ = _xapian.delete_ESet def get_ebound(*args): ''' A lower bound on the number of terms which are in the full set of results of the expand. Xapian::termcount Xapian::ESet::get_ebound() const This will be greater than or equal to size() ''' return _xapian.ESet_get_ebound(*args) def size(*args): ''' The number of terms in this E-Set. Xapian::termcount Xapian::ESet::size() const ''' return _xapian.ESet_size(*args) def empty(*args): ''' Test if this E-Set is empty. bool Xapian::ESet::empty() const ''' return _xapian.ESet_empty(*args) def begin(*args): ''' Iterator for the terms in this E-Set. ESetIterator Xapian::ESet::begin() const ''' return _xapian.ESet_begin(*args) def end(*args): ''' End iterator corresponding to begin(). ESetIterator Xapian::ESet::end() const ''' return _xapian.ESet_end(*args) def back(*args): ''' Iterator pointing to the last element of this E-Set. ESetIterator Xapian::ESet::back() const ''' return _xapian.ESet_back(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::ESet::get_description() const ''' return _xapian.ESet___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::ESet::get_description() const ''' return _xapian.ESet_get_description(*args) items = _swig_property(_xapian.ESet_items_get) ESet.get_ebound = new_instancemethod(_xapian.ESet_get_ebound, None, ESet) ESet.size = new_instancemethod(_xapian.ESet_size, None, ESet) ESet.empty = new_instancemethod(_xapian.ESet_empty, None, ESet) ESet.begin = new_instancemethod(_xapian.ESet_begin, None, ESet) ESet.end = new_instancemethod(_xapian.ESet_end, None, ESet) ESet.back = new_instancemethod(_xapian.ESet_back, None, ESet) ESet.__str__ = new_instancemethod(_xapian.ESet___str__, None, ESet) ESet.get_description = new_instancemethod(_xapian.ESet_get_description, None, ESet) ESet_swigregister = _xapian.ESet_swigregister ESet_swigregister(ESet) class ESetIterator(object): ''' Iterate through terms in the ESet. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Copying is allowed (and is cheap). Xapian::ESetIterator::ESetIterator(const ESetIterator &other) ''' _xapian.ESetIterator_swiginit(self, _xapian.new_ESetIterator(*args)) __swig_destroy__ = _xapian.delete_ESetIterator def get_weight(*args): ''' Get the weight of the term at the current position. Xapian::weight Xapian::ESetIterator::get_weight() const ''' return _xapian.ESetIterator_get_weight(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::ESetIterator::get_description() const ''' return _xapian.ESetIterator___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::ESetIterator::get_description() const ''' return _xapian.ESetIterator_get_description(*args) ESetIterator.get_termname = new_instancemethod(_xapian.ESetIterator_get_termname, None, ESetIterator) ESetIterator.get_term = new_instancemethod(_xapian.ESetIterator_get_term, None, ESetIterator) ESetIterator.next = new_instancemethod(_xapian.ESetIterator_next, None, ESetIterator) ESetIterator.prev = new_instancemethod(_xapian.ESetIterator_prev, None, ESetIterator) ESetIterator.equals = new_instancemethod(_xapian.ESetIterator_equals, None, ESetIterator) ESetIterator.get_weight = new_instancemethod(_xapian.ESetIterator_get_weight, None, ESetIterator) ESetIterator.__str__ = new_instancemethod(_xapian.ESetIterator___str__, None, ESetIterator) ESetIterator.get_description = new_instancemethod(_xapian.ESetIterator_get_description, None, ESetIterator) ESetIterator.__eq__ = new_instancemethod(_xapian.ESetIterator___eq__, None, ESetIterator) ESetIterator.__ne__ = new_instancemethod(_xapian.ESetIterator___ne__, None, ESetIterator) ESetIterator_swigregister = _xapian.ESetIterator_swigregister ESetIterator_swigregister(ESetIterator) class RSet(object): ''' A relevance set (R-Set). This is the set of documents which are marked as relevant, for use in modifying the term weights, and in performing query expansion. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Default constructor. Xapian::RSet::RSet() ''' _xapian.RSet_swiginit(self, _xapian.new_RSet(*args)) __swig_destroy__ = _xapian.delete_RSet def size(*args): ''' The number of documents in this R-Set. Xapian::doccount Xapian::RSet::size() const ''' return _xapian.RSet_size(*args) def empty(*args): ''' Test if this R-Set is empty. bool Xapian::RSet::empty() const ''' return _xapian.RSet_empty(*args) def add_document(*args): ''' Add a document to the relevance set. void Xapian::RSet::add_document(const Xapian::MSetIterator &i) ''' return _xapian.RSet_add_document(*args) def remove_document(*args): ''' Remove a document from the relevance set. void Xapian::RSet::remove_document(const Xapian::MSetIterator &i) ''' return _xapian.RSet_remove_document(*args) def contains(*args): ''' Test if a given document in the relevance set. bool Xapian::RSet::contains(const Xapian::MSetIterator &i) const ''' return _xapian.RSet_contains(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::RSet::get_description() const ''' return _xapian.RSet___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::RSet::get_description() const ''' return _xapian.RSet_get_description(*args) RSet.size = new_instancemethod(_xapian.RSet_size, None, RSet) RSet.empty = new_instancemethod(_xapian.RSet_empty, None, RSet) RSet.add_document = new_instancemethod(_xapian.RSet_add_document, None, RSet) RSet.remove_document = new_instancemethod(_xapian.RSet_remove_document, None, RSet) RSet.contains = new_instancemethod(_xapian.RSet_contains, None, RSet) RSet.__str__ = new_instancemethod(_xapian.RSet___str__, None, RSet) RSet.get_description = new_instancemethod(_xapian.RSet_get_description, None, RSet) RSet_swigregister = _xapian.RSet_swigregister RSet_swigregister(RSet) class MatchDecider(object): ''' Base class for matcher decision functor. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_MatchDecider def __init__(self, *args): if self.__class__ == MatchDecider: args = (None,) + args else: args = (self,) + args _xapian.MatchDecider_swiginit(self, _xapian.new_MatchDecider(*args)) def __disown__(self): self.this.disown() _xapian.disown_MatchDecider(self) return weakref_proxy(self) MatchDecider.__call__ = new_instancemethod(_xapian.MatchDecider___call__, None, MatchDecider) MatchDecider_swigregister = _xapian.MatchDecider_swigregister MatchDecider_swigregister(MatchDecider) class ExpandDecider(object): ''' Virtual base class for expand decider functor. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_ExpandDecider def __init__(self, *args): if self.__class__ == ExpandDecider: args = (None,) + args else: args = (self,) + args _xapian.ExpandDecider_swiginit(self, _xapian.new_ExpandDecider(*args)) def __disown__(self): self.this.disown() _xapian.disown_ExpandDecider(self) return weakref_proxy(self) ExpandDecider.__call__ = new_instancemethod(_xapian.ExpandDecider___call__, None, ExpandDecider) ExpandDecider_swigregister = _xapian.ExpandDecider_swigregister ExpandDecider_swigregister(ExpandDecider) class Enquire(object): ''' This class provides an interface to the information retrieval system for the purpose of searching. Databases are usually opened lazily, so exceptions may not be thrown where you would expect them to be. You should catch Xapian::Error exceptions when calling any method in Xapian::Enquire. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if an invalid argument is supplied, for example, an unknown database type. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Create a Xapian::Enquire object. Xapian::Enquire::Enquire(const Database &database, ErrorHandler *errorhandler_=0) This specification cannot be changed once the Xapian::Enquire is opened: you must create a new Xapian::Enquire object to access a different database, or set of databases. The database supplied must have been initialised (ie, must not be the result of calling the Database::Database() constructor). If you need to handle a situation where you have no index gracefully, a database created with InMemory::open() can be passed here, which represents a completely empty database. Parameters: ----------- database: Specification of the database or databases to use. errorhandler_: A pointer to the error handler to use. Ownership of the object pointed to is not assumed by the Xapian::Enquire object - the user should delete the Xapian::ErrorHandler object after the Xapian::Enquire object is deleted. To use no error handler, this parameter should be 0. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if an initialised Database object is supplied. ''' _xapian.Enquire_swiginit(self, _xapian.new_Enquire(*args)) __swig_destroy__ = _xapian.delete_Enquire def set_query(*args): ''' Set the query to run. void Xapian::Enquire::set_query(const Xapian::Query &query, Xapian::termcount qlen=0) Parameters: ----------- query: the new query to run. qlen: the query length to use in weight calculations - by default the sum of the wqf of all terms is used. ''' return _xapian.Enquire_set_query(*args) def get_query(*args): ''' Get the query which has been set. const Xapian::Query& Xapian::Enquire::get_query() const This is only valid after set_query() has been called. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if query has not yet been set. ''' return _xapian.Enquire_get_query(*args) def set_weighting_scheme(*args): ''' Set the weighting scheme to use for queries. void Xapian::Enquire::set_weighting_scheme(const Weight &weight_) Parameters: ----------- weight_: the new weighting scheme. If no weighting scheme is specified, the default is BM25 with the default parameters. ''' return _xapian.Enquire_set_weighting_scheme(*args) def set_collapse_key(*args): """ Set the collapse key to use for queries. void Xapian::Enquire::set_collapse_key(Xapian::valueno collapse_key) Parameters: ----------- collapse_key: value number to collapse on - at most one MSet entry with each particular value will be returned. The entry returned will be the best entry with that particular value (highest weight or highest sorting key). An example use might be to create a value for each document containing an MD5 hash of the document contents. Then duplicate documents from different sources can be eliminated at search time (it's better to eliminate duplicates at index time, but this may not be always be possible - for example the search may be over more than one Xapian database). Another use is to group matches in a particular category (e.g. you might collapse a mailing list search on the Subject: so that there's only one result per discussion thread). In this case you can use get_collapse_count() to give the user some idea how many other results there are. And if you index the Subject: as a boolean term as well as putting it in a value, you can offer a link to a non-collapsed search restricted to that thread using a boolean filter. (default is Xapian::BAD_VALUENO which means no collapsing). """ return _xapian.Enquire_set_collapse_key(*args) ASCENDING = _xapian.Enquire_ASCENDING DESCENDING = _xapian.Enquire_DESCENDING DONT_CARE = _xapian.Enquire_DONT_CARE def set_docid_order(*args): ''' Set the direction in which documents are ordered by document id in the returned MSet. void Xapian::Enquire::set_docid_order(docid_order order) This order only has an effect on documents which would otherwise have equal rank. For a weighted probabilistic match with no sort value, this means documents with equal weight. For a boolean match, with no sort value, this means all documents. And if a sort value is used, this means documents with equal sort value (and also equal weight if ordering on relevance after the sort). Parameters: ----------- order: This can be: Xapian::Enquire::ASCENDING docids sort in ascending order (default) Xapian::Enquire::DESCENDING docids sort in descending order Xapian::Enquire::DONT_CARE docids sort in whatever order is most efficient for the backend Note: If you add documents in strict date order, then a boolean search - i.e. set_weighting_scheme(Xapian::BoolWeight()) - with set_docid_order(Xapian::Enquire::DESCENDING) is a very efficient way to perform "sort by date, newest first". ''' return _xapian.Enquire_set_docid_order(*args) def set_cutoff(*args): """ Set the percentage and/or weight cutoffs. void Xapian::Enquire::set_cutoff(Xapian::percent percent_cutoff, Xapian::weight weight_cutoff=0) Parameters: ----------- percent_cutoff: Minimum percentage score for returned documents. If a document has a lower percentage score than this, it will not appear in the MSet. If your intention is to return only matches which contain all the terms in the query, then it's more efficient to use Xapian::Query::OP_AND instead of Xapian::Query::OP_OR in the query than to use set_cutoff(100). (default 0 => no percentage cut-off). weight_cutoff: Minimum weight for a document to be returned. If a document has a lower score that this, it will not appear in the MSet. It is usually only possible to choose an appropriate weight for cutoff based on the results of a previous run of the same query; this is thus mainly useful for alerting operations. The other potential use is with a user specified weighting scheme. (default 0 => no weight cut-off). """ return _xapian.Enquire_set_cutoff(*args) def set_sort_by_relevance(*args): ''' Set the sorting to be by relevance only. void Xapian::Enquire::set_sort_by_relevance() This is the default. ''' return _xapian.Enquire_set_sort_by_relevance(*args) def set_sort_by_value(*args): """ Set the sorting to be by value only. void Xapian::Enquire::set_sort_by_value(Xapian::valueno sort_key, bool ascending=true) NB sorting of values uses a string comparison, so you'll need to store numbers padded with leading zeros or spaces, or with the number of digits prepended. Parameters: ----------- sort_key: value number to sort on. ascending: If true, documents values which sort higher by string compare are better. If false, the sort order is reversed. (default true) """ return _xapian.Enquire_set_sort_by_value(*args) def set_sort_by_value_then_relevance(*args): """ Set the sorting to be by value, then by relevance for documents with the same value. void Xapian::Enquire::set_sort_by_value_then_relevance(Xapian::valueno sort_key, bool ascending=true) NB sorting of values uses a string comparison, so you'll need to store numbers padded with leading zeros or spaces, or with the number of digits prepended. Parameters: ----------- sort_key: value number to sort on. ascending: If true, documents values which sort higher by string compare are better. If false, the sort order is reversed. (default true) """ return _xapian.Enquire_set_sort_by_value_then_relevance(*args) def set_sort_by_relevance_then_value(*args): """ Set the sorting to be by relevance then value. void Xapian::Enquire::set_sort_by_relevance_then_value(Xapian::valueno sort_key, bool ascending=true) NB sorting of values uses a string comparison, so you'll need to store numbers padded with leading zeros or spaces, or with the number of digits prepended. Note that with the default BM25 weighting scheme parameters, non- identical documents will rarely have the same weight, so this setting will give very similar results to set_sort_by_relevance(). It becomes more useful with particular BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom weighting schemes. Parameters: ----------- sort_key: value number to sort on. ascending: If true, documents values which sort higher by string compare are better. If false, the sort order is reversed. (default true) """ return _xapian.Enquire_set_sort_by_relevance_then_value(*args) def set_sort_by_key(*args): ''' Set the sorting to be by key generated from values only. void Xapian::Enquire::set_sort_by_key(Xapian::Sorter *sorter, bool ascending=true) Parameters: ----------- sorter: The functor to use for generating keys. ascending: If true, documents values which sort higher by string compare are better. If false, the sort order is reversed. (default true) ''' return _xapian.Enquire_set_sort_by_key(*args) def set_sort_by_key_then_relevance(*args): ''' Set the sorting to be by keys generated from values, then by relevance for documents with identical keys. void Xapian::Enquire::set_sort_by_key_then_relevance(Xapian::Sorter *sorter, bool ascending=true) Parameters: ----------- sorter: The functor to use for generating keys. ascending: If true, keys which sort higher by string compare are better. If false, the sort order is reversed. (default true) ''' return _xapian.Enquire_set_sort_by_key_then_relevance(*args) def set_sort_by_relevance_then_key(*args): ''' Set the sorting to be by relevance, then by keys generated from values. void Xapian::Enquire::set_sort_by_relevance_then_key(Xapian::Sorter *sorter, bool ascending=true) Note that with the default BM25 weighting scheme parameters, non- identical documents will rarely have the same weight, so this setting will give very similar results to set_sort_by_relevance(). It becomes more useful with particular BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom weighting schemes. Parameters: ----------- sorter: The functor to use for generating keys. ascending: If true, keys which sort higher by string compare are better. If false, the sort order is reversed. (default true) ''' return _xapian.Enquire_set_sort_by_relevance_then_key(*args) INCLUDE_QUERY_TERMS = _xapian.Enquire_INCLUDE_QUERY_TERMS USE_EXACT_TERMFREQ = _xapian.Enquire_USE_EXACT_TERMFREQ def get_mset(*args): ''' MSet Xapian::Enquire::get_mset(Xapian::doccount first, Xapian::doccount maxitems, const RSet *omrset, const MatchDecider *mdecider=0) const ''' return _xapian.Enquire_get_mset(*args) def get_eset(*args): ''' Get the expand set for the given rset. ESet Xapian::Enquire::get_eset(Xapian::termcount maxitems, const RSet &omrset, const Xapian::ExpandDecider *edecider) const Parameters: ----------- maxitems: the maximum number of items to return. omrset: the relevance set to use when performing the expand operation. edecider: a decision functor to use to decide whether a given term should be put in the ESet An ESet object containing the results of the expand. Parameters: ----------- Xapian::InvalidArgumentError: See class documentation. ''' return _xapian.Enquire_get_eset(*args) def get_matching_terms_begin(*args): ''' Get terms which match a given document, by match set item. TermIterator Xapian::Enquire::get_matching_terms_begin(const MSetIterator &it) const This method returns the terms in the current query which match the given document. If the underlying database has suitable support, using this call (rather than passing a Xapian::docid) will enable the system to ensure that the correct data is returned, and that the document has not been deleted or changed since the query was performed. Parameters: ----------- it: The iterator for which to retrieve the matching terms. An iterator returning the terms which match the document. The terms will be returned (as far as this makes any sense) in the same order as the terms in the query. Terms will not occur more than once, even if they do in the query. Parameters: ----------- Xapian::InvalidArgumentError: See class documentation. Xapian::DocNotFoundError: The document specified could not be found in the database. ''' return _xapian.Enquire_get_matching_terms_begin(*args) def get_matching_terms_end(*args): ''' End iterator corresponding to get_matching_terms_begin(). TermIterator Xapian::Enquire::get_matching_terms_end(const MSetIterator &) const ''' return _xapian.Enquire_get_matching_terms_end(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::Enquire::get_description() const ''' return _xapian.Enquire___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::Enquire::get_description() const ''' return _xapian.Enquire_get_description(*args) Enquire.set_query = new_instancemethod(_xapian.Enquire_set_query, None, Enquire) Enquire.get_query = new_instancemethod(_xapian.Enquire_get_query, None, Enquire) Enquire.set_weighting_scheme = new_instancemethod(_xapian.Enquire_set_weighting_scheme, None, Enquire) Enquire.set_collapse_key = new_instancemethod(_xapian.Enquire_set_collapse_key, None, Enquire) Enquire.set_docid_order = new_instancemethod(_xapian.Enquire_set_docid_order, None, Enquire) Enquire.set_cutoff = new_instancemethod(_xapian.Enquire_set_cutoff, None, Enquire) Enquire.set_sort_by_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_relevance, None, Enquire) Enquire.set_sort_by_value = new_instancemethod(_xapian.Enquire_set_sort_by_value, None, Enquire) Enquire.set_sort_by_value_then_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_value_then_relevance, None, Enquire) Enquire.set_sort_by_relevance_then_value = new_instancemethod(_xapian.Enquire_set_sort_by_relevance_then_value, None, Enquire) Enquire.set_sort_by_key = new_instancemethod(_xapian.Enquire_set_sort_by_key, None, Enquire) Enquire.set_sort_by_key_then_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_key_then_relevance, None, Enquire) Enquire.set_sort_by_relevance_then_key = new_instancemethod(_xapian.Enquire_set_sort_by_relevance_then_key, None, Enquire) Enquire.get_mset = new_instancemethod(_xapian.Enquire_get_mset, None, Enquire) Enquire.get_eset = new_instancemethod(_xapian.Enquire_get_eset, None, Enquire) Enquire.get_matching_terms_begin = new_instancemethod(_xapian.Enquire_get_matching_terms_begin, None, Enquire) Enquire.get_matching_terms_end = new_instancemethod(_xapian.Enquire_get_matching_terms_end, None, Enquire) Enquire.register_match_decider = new_instancemethod(_xapian.Enquire_register_match_decider, None, Enquire) Enquire.get_matching_terms = new_instancemethod(_xapian.Enquire_get_matching_terms, None, Enquire) Enquire.__str__ = new_instancemethod(_xapian.Enquire___str__, None, Enquire) Enquire.get_description = new_instancemethod(_xapian.Enquire_get_description, None, Enquire) Enquire_swigregister = _xapian.Enquire_swigregister Enquire_swigregister(Enquire) class Weight(object): ''' Abstract base class for weighting schemes. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') def __init__(self): raise AttributeError, 'No constructor defined' __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_Weight def name(*args): ''' Name of the weighting scheme. virtual std::string Xapian::Weight::name() const=0 If the subclass is called FooWeight, this should return "Foo". ''' return _xapian.Weight_name(*args) def serialise(*args): ''' Serialise object parameters into a string. virtual std::string Xapian::Weight::serialise() const=0 ''' return _xapian.Weight_serialise(*args) def unserialise(*args): ''' Create object given string serialisation returned by serialise(). virtual Weight* Xapian::Weight::unserialise(const std::string &s) const=0 ''' return _xapian.Weight_unserialise(*args) def get_sumpart(*args): ''' Get a weight which is part of the sum over terms being performed. virtual Xapian::weight Xapian::Weight::get_sumpart(Xapian::termcount wdf, Xapian::doclength len) const=0 This returns a weight for a given term and document. These weights are summed to give a total weight for the document. Parameters: ----------- wdf: the within document frequency of the term. len: the (unnormalised) document length. ''' return _xapian.Weight_get_sumpart(*args) def get_maxpart(*args): ''' Gets the maximum value that get_sumpart() may return. virtual Xapian::weight Xapian::Weight::get_maxpart() const=0 This is used in optimising searches, by having the postlist tree decay appropriately when parts of it can have limited, or no, further effect. ''' return _xapian.Weight_get_maxpart(*args) def get_sumextra(*args): ''' Get an extra weight for a document to add to the sum calculated over the query terms. virtual Xapian::weight Xapian::Weight::get_sumextra(Xapian::doclength len) const=0 This returns a weight for a given document, and is used by some weighting schemes to account for influence such as document length. Parameters: ----------- len: the (unnormalised) document length. ''' return _xapian.Weight_get_sumextra(*args) def get_maxextra(*args): ''' Gets the maximum value that get_sumextra() may return. virtual Xapian::weight Xapian::Weight::get_maxextra() const=0 This is used in optimising searches. ''' return _xapian.Weight_get_maxextra(*args) def get_sumpart_needs_doclength(*args): """ return false if the weight object doesn't need doclength virtual bool Xapian::Weight::get_sumpart_needs_doclength() const """ return _xapian.Weight_get_sumpart_needs_doclength(*args) Weight.name = new_instancemethod(_xapian.Weight_name, None, Weight) Weight.serialise = new_instancemethod(_xapian.Weight_serialise, None, Weight) Weight.unserialise = new_instancemethod(_xapian.Weight_unserialise, None, Weight) Weight.get_sumpart = new_instancemethod(_xapian.Weight_get_sumpart, None, Weight) Weight.get_maxpart = new_instancemethod(_xapian.Weight_get_maxpart, None, Weight) Weight.get_sumextra = new_instancemethod(_xapian.Weight_get_sumextra, None, Weight) Weight.get_maxextra = new_instancemethod(_xapian.Weight_get_maxextra, None, Weight) Weight.get_sumpart_needs_doclength = new_instancemethod(_xapian.Weight_get_sumpart_needs_doclength, None, Weight) Weight_swigregister = _xapian.Weight_swigregister Weight_swigregister(Weight) class BoolWeight(Weight): ''' Boolean weighting scheme (everything gets 0). ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def clone(*args): ''' Return a new weight object of this type. BoolWeight* Xapian::BoolWeight::clone() const A subclass called FooWeight taking parameters param1 and param2 should implement this as: virtual FooWeight * clone() const { return new FooWeight(param1, param2); } ''' return _xapian.BoolWeight_clone(*args) def __init__(self, *args): '''Xapian::BoolWeight::BoolWeight() ''' _xapian.BoolWeight_swiginit(self, _xapian.new_BoolWeight(*args)) __swig_destroy__ = _xapian.delete_BoolWeight def unserialise(*args): ''' Create object given string serialisation returned by serialise(). BoolWeight* Xapian::BoolWeight::unserialise(const std::string &s) const ''' return _xapian.BoolWeight_unserialise(*args) BoolWeight.clone = new_instancemethod(_xapian.BoolWeight_clone, None, BoolWeight) BoolWeight.unserialise = new_instancemethod(_xapian.BoolWeight_unserialise, None, BoolWeight) BoolWeight_swigregister = _xapian.BoolWeight_swigregister BoolWeight_swigregister(BoolWeight) class BM25Weight(Weight): ''' BM25 weighting scheme. BM25 weighting options : The BM25 formula is \\[ \\frac{k_{2}.n_{q}}{1+L_{d}}+\\sum_{t}\\frac{(k_{3}+1)q_{t }}{k_{3}+q_{t}}.\\frac{(k_{1}+1)f_{t,d}}{k_{1}((1-b)+bL_{d})+f_{t,d} }.w_{t} \\] where $w_{t}$ is the termweight of term t $f_{t,d}$ is the within document frequency of term t in document d $q_{t}$ is the within query frequency of term t $L_{d}$ is the normalised length of document d $n_{q}$ is the size of the query $k_{1}$, $k_{2}$, $k_{3}$ and $b$ are user specified parameters ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): '''Xapian::BM25Weight::BM25Weight() ''' _xapian.BM25Weight_swiginit(self, _xapian.new_BM25Weight(*args)) def clone(*args): ''' Return a new weight object of this type. BM25Weight* Xapian::BM25Weight::clone() const A subclass called FooWeight taking parameters param1 and param2 should implement this as: virtual FooWeight * clone() const { return new FooWeight(param1, param2); } ''' return _xapian.BM25Weight_clone(*args) __swig_destroy__ = _xapian.delete_BM25Weight def unserialise(*args): ''' Create object given string serialisation returned by serialise(). BM25Weight* Xapian::BM25Weight::unserialise(const std::string &s) const ''' return _xapian.BM25Weight_unserialise(*args) BM25Weight.clone = new_instancemethod(_xapian.BM25Weight_clone, None, BM25Weight) BM25Weight.unserialise = new_instancemethod(_xapian.BM25Weight_unserialise, None, BM25Weight) BM25Weight_swigregister = _xapian.BM25Weight_swigregister BM25Weight_swigregister(BM25Weight) class TradWeight(Weight): ''' Traditional probabilistic weighting scheme. This class implements the Traditional Probabilistic Weighting scheme, as described by the early papers on Probabilistic Retrieval. BM25 generally gives better results. The Traditional weighting scheme formula is \\[ \\sum_{t}\\frac{f_{t,d}}{k.L_{d}+f_{t,d}}.w_{t} \\] where $w_{t}$ is the termweight of term t $f_{t,d}$ is the within document frequency of term t in document d $L_{d}$ is the normalised length of document d $k$ is a user specifiable parameter TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that the latter returns weights (k+1) times larger. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): '''Xapian::TradWeight::TradWeight() ''' _xapian.TradWeight_swiginit(self, _xapian.new_TradWeight(*args)) def clone(*args): ''' Return a new weight object of this type. TradWeight* Xapian::TradWeight::clone() const A subclass called FooWeight taking parameters param1 and param2 should implement this as: virtual FooWeight * clone() const { return new FooWeight(param1, param2); } ''' return _xapian.TradWeight_clone(*args) __swig_destroy__ = _xapian.delete_TradWeight def unserialise(*args): ''' Create object given string serialisation returned by serialise(). TradWeight* Xapian::TradWeight::unserialise(const std::string &s) const ''' return _xapian.TradWeight_unserialise(*args) TradWeight.clone = new_instancemethod(_xapian.TradWeight_clone, None, TradWeight) TradWeight.unserialise = new_instancemethod(_xapian.TradWeight_unserialise, None, TradWeight) TradWeight_swigregister = _xapian.TradWeight_swigregister TradWeight_swigregister(TradWeight) class Database(object): ''' This class is used to access a database, or a group of databases. For searching, this class is used in conjunction with an Enquire object. Parameters: ----------- InvalidArgumentError: will be thrown if an invalid argument is supplied, for example, an unknown database type. DatabaseOpeningError: may be thrown if the database cannot be opened (for example, a required file cannot be found). DatabaseVersionError: may be thrown if the database is in an unsupported format (for example, created by a newer version of Xapian which uses an incompatible format). ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def add_database(*args): ''' Add an existing database (or group of databases) to those accessed by this object. void Xapian::Database::add_database(const Database &database) Parameters: ----------- database: the database(s) to add. ''' return _xapian.Database_add_database(*args) __swig_destroy__ = _xapian.delete_Database def __init__(self, *args): ''' Copying is allowed. Xapian::Database::Database(const Database &other) The internals are reference counted, so copying is cheap. ''' _xapian.Database_swiginit(self, _xapian.new_Database(*args)) def reopen(*args): ''' Re-open the database. void Xapian::Database::reopen() This re-opens the database(s) to the latest available version(s). It can be used either to make sure the latest results are returned, or to recover from a Xapian::DatabaseModifiedError. ''' return _xapian.Database_reopen(*args) def __str__(*args): ''' Return a string describing this object. virtual std::string Xapian::Database::get_description() const ''' return _xapian.Database___str__(*args) def postlist_begin(*args): ''' An iterator pointing to the start of the postlist for a given term. PostingIterator Xapian::Database::postlist_begin(const std::string &tname) const If the term name is the empty string, the iterator returned will list all the documents in the database. Such an iterator will always return a WDF value of 1, since there is no obvious meaning for this quantity in this case. ''' return _xapian.Database_postlist_begin(*args) def postlist_end(*args): ''' Corresponding end iterator to postlist_begin(). PostingIterator Xapian::Database::postlist_end(const std::string &) const ''' return _xapian.Database_postlist_end(*args) def termlist_begin(*args): ''' An iterator pointing to the start of the termlist for a given document. TermIterator Xapian::Database::termlist_begin(Xapian::docid did) const ''' return _xapian.Database_termlist_begin(*args) def termlist_end(*args): ''' Corresponding end iterator to termlist_begin(). TermIterator Xapian::Database::termlist_end(Xapian::docid) const ''' return _xapian.Database_termlist_end(*args) def positionlist_begin(*args): ''' An iterator pointing to the start of the position list for a given term in a given document. PositionIterator Xapian::Database::positionlist_begin(Xapian::docid did, const std::string &tname) const ''' return _xapian.Database_positionlist_begin(*args) def positionlist_end(*args): ''' Corresponding end iterator to positionlist_begin(). PositionIterator Xapian::Database::positionlist_end(Xapian::docid, const std::string &) const ''' return _xapian.Database_positionlist_end(*args) def allterms_begin(*args): ''' An iterator which runs across all terms with a given prefix. TermIterator Xapian::Database::allterms_begin(const std::string &prefix) const This is functionally similar to getting an iterator with allterms_begin() and then calling skip_to(prefix) on that iterator to move to the start of the prefix, but is more convenient (because it detects the end of the prefixed terms), and may be more efficient than simply calling skip_to() after opening the iterator, particularly for network databases. Parameters: ----------- prefix: The prefix to restrict the returned terms to. ''' return _xapian.Database_allterms_begin(*args) def allterms_end(*args): ''' Corresponding end iterator to allterms_begin(prefix). TermIterator Xapian::Database::allterms_end(const std::string &) const ''' return _xapian.Database_allterms_end(*args) def get_doccount(*args): ''' Get the number of documents in the database. Xapian::doccount Xapian::Database::get_doccount() const ''' return _xapian.Database_get_doccount(*args) def get_lastdocid(*args): ''' Get the highest document id which has been used in the database. Xapian::docid Xapian::Database::get_lastdocid() const ''' return _xapian.Database_get_lastdocid(*args) def get_avlength(*args): ''' Get the average length of the documents in the database. Xapian::doclength Xapian::Database::get_avlength() const ''' return _xapian.Database_get_avlength(*args) def get_termfreq(*args): ''' Get the number of documents in the database indexed by a given term. Xapian::doccount Xapian::Database::get_termfreq(const std::string &tname) const ''' return _xapian.Database_get_termfreq(*args) def term_exists(*args): ''' Check if a given term exists in the database. bool Xapian::Database::term_exists(const std::string &tname) const Return true if and only if the term exists in the database. This is the same as (get_termfreq(tname) != 0), but will often be more efficient. ''' return _xapian.Database_term_exists(*args) def get_collection_freq(*args): ''' Return the total number of occurrences of the given term. Xapian::termcount Xapian::Database::get_collection_freq(const std::string &tname) const This is the sum of the number of occurrences of the term in each document it indexes: i.e., the sum of the within document frequencies of the term. Parameters: ----------- tname: The term whose collection frequency is being requested. ''' return _xapian.Database_get_collection_freq(*args) def get_doclength(*args): ''' Get the length of a document. Xapian::doclength Xapian::Database::get_doclength(Xapian::docid did) const ''' return _xapian.Database_get_doclength(*args) def keep_alive(*args): ''' Send a "keep-alive" to remote databases to stop them timing out. void Xapian::Database::keep_alive() ''' return _xapian.Database_keep_alive(*args) def get_document(*args): ''' Get a document from the database, given its document id. Xapian::Document Xapian::Database::get_document(Xapian::docid did) const This method returns a Xapian::Document object which provides the information about a document. Parameters: ----------- did: The document id for which to retrieve the data. A Xapian::Document object containing the document data Parameters: ----------- Xapian::DocNotFoundError: The document specified could not be found in the database. ''' return _xapian.Database_get_document(*args) def get_spelling_suggestion(*args): ''' Suggest a spelling correction. std::string Xapian::Database::get_spelling_suggestion(const std::string &word, unsigned max_edit_distance=2) const Parameters: ----------- word: The potentially misspelled word. max_edit_distance: Only consider words which are at most max_edit_distance edits from word. An edit is a character insertion, deletion, or the transposition of two adjacent characters (default is 2). ''' return _xapian.Database_get_spelling_suggestion(*args) def spellings_begin(*args): ''' An iterator which returns all the spelling correction targets. Xapian::TermIterator Xapian::Database::spellings_begin() const This returns all the words which are considered as targets for the spelling correction algorithm. The frequency of each word is available as the term frequency of each entry in the returned iterator. ''' return _xapian.Database_spellings_begin(*args) def spellings_end(*args): ''' Corresponding end iterator to spellings_begin(). Xapian::TermIterator Xapian::Database::spellings_end() const ''' return _xapian.Database_spellings_end(*args) def synonyms_begin(*args): ''' An iterator which returns all the synonyms for a given term. Xapian::TermIterator Xapian::Database::synonyms_begin(const std::string &term) const Parameters: ----------- term: The term to return synonyms for. ''' return _xapian.Database_synonyms_begin(*args) def synonyms_end(*args): ''' Corresponding end iterator to synonyms_begin(term). Xapian::TermIterator Xapian::Database::synonyms_end(const std::string &) const ''' return _xapian.Database_synonyms_end(*args) def synonym_keys_begin(*args): ''' An iterator which returns all terms which have synonyms. Xapian::TermIterator Xapian::Database::synonym_keys_begin(const std::string &prefix="") const Parameters: ----------- prefix: If non-empty, only terms with this prefix are returned. ''' return _xapian.Database_synonym_keys_begin(*args) def synonym_keys_end(*args): ''' Corresponding end iterator to synonym_keys_begin(prefix). Xapian::TermIterator Xapian::Database::synonym_keys_end(const std::string &="") const ''' return _xapian.Database_synonym_keys_end(*args) def get_metadata(*args): """ Get the user-specified metadata associated with a given key. std::string Xapian::Database::get_metadata(const std::string &key) const User-specified metadata allows you to store arbitrary information in the form of (key,tag) pairs. See WritableDatabase::set_metadata() for more information. When invoked on a Xapian::Database object representing multiple databases, currently only the metadata for the first is considered but this behaviour may change in the future. If there is no piece of metadata associated with the specified key, an empty string is returned (this applies even for backends which don't support metadata). Empty keys are not valid, and specifying one will cause an exception. Parameters: ----------- key: The key of the metadata item to access. The retrieved metadata item's value. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if the key supplied is empty. Xapian::UnimplementedError: will be thrown if the database backend in use doesn't support user- specified metadata. """ return _xapian.Database_get_metadata(*args) def get_description(*args): ''' Return a string describing this object. virtual std::string Xapian::Database::get_description() const ''' return _xapian.Database_get_description(*args) Database.add_database = new_instancemethod(_xapian.Database_add_database, None, Database) Database.reopen = new_instancemethod(_xapian.Database_reopen, None, Database) Database.__str__ = new_instancemethod(_xapian.Database___str__, None, Database) Database.postlist_begin = new_instancemethod(_xapian.Database_postlist_begin, None, Database) Database.postlist_end = new_instancemethod(_xapian.Database_postlist_end, None, Database) Database.termlist_begin = new_instancemethod(_xapian.Database_termlist_begin, None, Database) Database.termlist_end = new_instancemethod(_xapian.Database_termlist_end, None, Database) Database.positionlist_begin = new_instancemethod(_xapian.Database_positionlist_begin, None, Database) Database.positionlist_end = new_instancemethod(_xapian.Database_positionlist_end, None, Database) Database.allterms_begin = new_instancemethod(_xapian.Database_allterms_begin, None, Database) Database.allterms_end = new_instancemethod(_xapian.Database_allterms_end, None, Database) Database.get_doccount = new_instancemethod(_xapian.Database_get_doccount, None, Database) Database.get_lastdocid = new_instancemethod(_xapian.Database_get_lastdocid, None, Database) Database.get_avlength = new_instancemethod(_xapian.Database_get_avlength, None, Database) Database.get_termfreq = new_instancemethod(_xapian.Database_get_termfreq, None, Database) Database.term_exists = new_instancemethod(_xapian.Database_term_exists, None, Database) Database.get_collection_freq = new_instancemethod(_xapian.Database_get_collection_freq, None, Database) Database.get_doclength = new_instancemethod(_xapian.Database_get_doclength, None, Database) Database.keep_alive = new_instancemethod(_xapian.Database_keep_alive, None, Database) Database.get_document = new_instancemethod(_xapian.Database_get_document, None, Database) Database.get_spelling_suggestion = new_instancemethod(_xapian.Database_get_spelling_suggestion, None, Database) Database.spellings_begin = new_instancemethod(_xapian.Database_spellings_begin, None, Database) Database.spellings_end = new_instancemethod(_xapian.Database_spellings_end, None, Database) Database.synonyms_begin = new_instancemethod(_xapian.Database_synonyms_begin, None, Database) Database.synonyms_end = new_instancemethod(_xapian.Database_synonyms_end, None, Database) Database.synonym_keys_begin = new_instancemethod(_xapian.Database_synonym_keys_begin, None, Database) Database.synonym_keys_end = new_instancemethod(_xapian.Database_synonym_keys_end, None, Database) Database.get_metadata = new_instancemethod(_xapian.Database_get_metadata, None, Database) Database.get_description = new_instancemethod(_xapian.Database_get_description, None, Database) Database_swigregister = _xapian.Database_swigregister Database_swigregister(Database) class WritableDatabase(Database): ''' This class provides read/write access to a database. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_WritableDatabase def __init__(self, *args): ''' Copying is allowed. Xapian::WritableDatabase::WritableDatabase(const WritableDatabase &other) The internals are reference counted, so copying is cheap. ''' _xapian.WritableDatabase_swiginit(self, _xapian.new_WritableDatabase(*args)) def flush(*args): """ Flush to disk any modifications made to the database. void Xapian::WritableDatabase::flush() For efficiency reasons, when performing multiple updates to a database it is best (indeed, almost essential) to make as many modifications as memory will permit in a single pass through the database. To ensure this, Xapian batches up modifications. Flush may be called at any time to ensure that the modifications which have been made are written to disk: if the flush succeeds, all the preceding modifications will have been written to disk. If any of the modifications fail, an exception will be thrown and the database will be left in a state in which each separate addition, replacement or deletion operation has either been fully performed or not performed at all: it is then up to the application to work out which operations need to be repeated. It's not valid to call flush within a transaction. Beware of calling flush too frequently: this will have a severe performance cost. Note that flush need not be called explicitly: it will be called automatically when the database is closed, or when a sufficient number of modifications have been made. Parameters: ----------- Xapian::DatabaseError: will be thrown if a problem occurs while modifying the database. Xapian::DatabaseCorruptError: will be thrown if the database is in a corrupt state. Xapian::DatabaseLockError: will be thrown if a lock couldn't be acquired on the database. """ return _xapian.WritableDatabase_flush(*args) def begin_transaction(*args): """ Begin a transaction. void Xapian::WritableDatabase::begin_transaction(bool flushed=true) In Xapian a transaction is a group of modifications to the database which are linked such that either all will be applied simultaneously or none will be applied at all. Even in the case of a power failure, this characteristic should be preserved (as long as the filesystem isn't corrupted, etc). A transaction is started with begin_transaction() and can either be committed by calling commit_transaction() or aborted by calling cancel_transaction(). By default, a transaction implicitly calls flush before and after so that the modifications stand and fall without affecting modifications before or after. The downside of this flushing is that small transactions cause modifications to be frequently flushed which can harm indexing performance in the same way that explicitly calling flush frequently can. If you're applying atomic groups of changes and only wish to ensure that each group is either applied or not applied, then you can prevent the automatic flush before and after the transaction by starting the transaction with begin_transaction(false). However, if cancel_transaction is called (or if commit_transaction isn't called before the WritableDatabase object is destroyed) then any changes which were pending before the transaction began will also be discarded. Transactions aren't currently supported by the InMemory backend. Parameters: ----------- Xapian::UnimplementedError: will be thrown if transactions are not available for this database type. Xapian::InvalidOperationError: will be thrown if this is called at an invalid time, such as when a transaction is already in progress. """ return _xapian.WritableDatabase_begin_transaction(*args) def commit_transaction(*args): ''' Complete the transaction currently in progress. void Xapian::WritableDatabase::commit_transaction() If this method completes successfully and this is a flushed transaction, all the database modifications made during the transaction will have been committed to the database. If an error occurs, an exception will be thrown, and none of the modifications made to the database during the transaction will have been applied to the database. In all cases the transaction will no longer be in progress. Parameters: ----------- Xapian::DatabaseError: will be thrown if a problem occurs while modifying the database. Xapian::DatabaseCorruptError: will be thrown if the database is in a corrupt state. Xapian::InvalidOperationError: will be thrown if a transaction is not currently in progress. Xapian::UnimplementedError: will be thrown if transactions are not available for this database type. ''' return _xapian.WritableDatabase_commit_transaction(*args) def cancel_transaction(*args): ''' Abort the transaction currently in progress, discarding the potential modifications made to the database. void Xapian::WritableDatabase::cancel_transaction() If an error occurs in this method, an exception will be thrown, but the transaction will be cancelled anyway. Parameters: ----------- Xapian::DatabaseError: will be thrown if a problem occurs while modifying the database. Xapian::DatabaseCorruptError: will be thrown if the database is in a corrupt state. Xapian::InvalidOperationError: will be thrown if a transaction is not currently in progress. Xapian::UnimplementedError: will be thrown if transactions are not available for this database type. ''' return _xapian.WritableDatabase_cancel_transaction(*args) def add_document(*args): """ Add a new document to the database. Xapian::docid Xapian::WritableDatabase::add_document(const Xapian::Document &document) This method adds the specified document to the database, returning a newly allocated document ID. Automatically allocated document IDs come from a per-database monotonically increasing counter, so IDs from deleted documents won't be reused. If you want to specify the document ID to be used, you should call replace_document() instead. Note that changes to the database won't be immediately committed to disk; see flush() for more details. As with all database modification operations, the effect is atomic: the document will either be fully added, or the document fails to be added and an exception is thrown (possibly at a later time when flush is called or the database is closed). Parameters: ----------- document: The new document to be added. The document ID of the newly added document. Parameters: ----------- Xapian::DatabaseError: will be thrown if a problem occurs while writing to the database. Xapian::DatabaseCorruptError: will be thrown if the database is in a corrupt state. """ return _xapian.WritableDatabase_add_document(*args) def delete_document(*args): ''' Delete any documents indexed by a term from the database. void Xapian::WritableDatabase::delete_document(const std::string &unique_term) This method removes any documents indexed by the specified term from the database. A major use is for convenience when UIDs from another system are mapped to terms in Xapian, although this method has other uses (for example, you could add a "deletion date" term to documents at index time and use this method to delete all documents due for deletion on a particular date). Parameters: ----------- unique_term: The term to remove references to. Parameters: ----------- Xapian::DatabaseError: will be thrown if a problem occurs while writing to the database. Xapian::DatabaseCorruptError: will be thrown if the database is in a corrupt state. ''' return _xapian.WritableDatabase_delete_document(*args) def replace_document(*args): ''' Replace any documents matching a term. Xapian::docid Xapian::WritableDatabase::replace_document(const std::string &unique_term, const Xapian::Document &document) This method replaces any documents indexed by the specified term with the specified document. If any documents are indexed by the term, the lowest document ID will be used for the document, otherwise a new document ID will be generated as for add_document. The intended use is to allow UIDs from another system to easily be mapped to terms in Xapian, although this method probably has other uses. Note that changes to the database won\'t be immediately committed to disk; see flush() for more details. As with all database modification operations, the effect is atomic: the document(s) will either be fully replaced, or the document(s) fail to be replaced and an exception is thrown (possibly at a later time when flush is called or the database is closed). Parameters: ----------- unique_term: The "unique" term. document: The new document. The document ID that document was given. Parameters: ----------- Xapian::DatabaseError: will be thrown if a problem occurs while writing to the database. Xapian::DatabaseCorruptError: will be thrown if the database is in a corrupt state. ''' return _xapian.WritableDatabase_replace_document(*args) def add_spelling(*args): ''' Add a word to the spelling dictionary. void Xapian::WritableDatabase::add_spelling(const std::string &word, Xapian::termcount freqinc=1) const If the word is already present, its frequency is increased. Parameters: ----------- word: The word to add. freqinc: How much to increase its frequency by (default 1). ''' return _xapian.WritableDatabase_add_spelling(*args) def remove_spelling(*args): """ Remove a word from the spelling dictionary. void Xapian::WritableDatabase::remove_spelling(const std::string &word, Xapian::termcount freqdec=1) const The word's frequency is decreased, and if would become zero or less then the word is removed completely. Parameters: ----------- word: The word to remove. freqdec: How much to decrease its frequency by (default 1). """ return _xapian.WritableDatabase_remove_spelling(*args) def add_synonym(*args): ''' Add a synonym for a term. void Xapian::WritableDatabase::add_synonym(const std::string &term, const std::string &synonym) const If synonym is already a synonym for term, then no action is taken. ''' return _xapian.WritableDatabase_add_synonym(*args) def remove_synonym(*args): """ Remove a synonym for a term. void Xapian::WritableDatabase::remove_synonym(const std::string &term, const std::string &synonym) const If synonym isn't a synonym for term, then no action is taken. """ return _xapian.WritableDatabase_remove_synonym(*args) def clear_synonyms(*args): ''' Remove all synonyms for a term. void Xapian::WritableDatabase::clear_synonyms(const std::string &term) const If term has no synonyms, no action is taken. ''' return _xapian.WritableDatabase_clear_synonyms(*args) def set_metadata(*args): """ Set the user-specified metadata associated with a given key. void Xapian::WritableDatabase::set_metadata(const std::string &key, const std::string &value) This method sets the metadata value associated with a given key. If there is already a metadata value stored in the database with the same key, the old value is replaced. If you want to delete an existing item of metadata, just set its value to the empty string. User-specified metadata allows you to store arbitrary information in the form of (key,tag) pairs. There's no hard limit on the number of metadata items, or the size of the metadata values. Metadata keys have a limited length, which depends on the backend. We recommend limiting them to 200 bytes. Empty keys are not valid, and specifying one will cause an exception. Metadata modifications are committed to disk in the same way as modifications to the documents in the database are: i.e., modifications are atomic, and won't be committed to disk immediately (see flush() for more details). This allows metadata to be used to link databases with versioned external resources by storing the appropriate version number in a metadata item. You can also use the metadata to store arbitrary extra information associated with terms, documents, or postings by encoding the termname and/or document id into the metadata key. Parameters: ----------- key: The key of the metadata item to set. value: The value of the metadata item to set. Parameters: ----------- Xapian::DatabaseError: will be thrown if a problem occurs while writing to the database. Xapian::DatabaseCorruptError: will be thrown if the database is in a corrupt state. Xapian::InvalidArgumentError: will be thrown if the key supplied is empty. """ return _xapian.WritableDatabase_set_metadata(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::WritableDatabase::get_description() const ''' return _xapian.WritableDatabase___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::WritableDatabase::get_description() const ''' return _xapian.WritableDatabase_get_description(*args) WritableDatabase.flush = new_instancemethod(_xapian.WritableDatabase_flush, None, WritableDatabase) WritableDatabase.begin_transaction = new_instancemethod(_xapian.WritableDatabase_begin_transaction, None, WritableDatabase) WritableDatabase.commit_transaction = new_instancemethod(_xapian.WritableDatabase_commit_transaction, None, WritableDatabase) WritableDatabase.cancel_transaction = new_instancemethod(_xapian.WritableDatabase_cancel_transaction, None, WritableDatabase) WritableDatabase.add_document = new_instancemethod(_xapian.WritableDatabase_add_document, None, WritableDatabase) WritableDatabase.delete_document = new_instancemethod(_xapian.WritableDatabase_delete_document, None, WritableDatabase) WritableDatabase.replace_document = new_instancemethod(_xapian.WritableDatabase_replace_document, None, WritableDatabase) WritableDatabase.add_spelling = new_instancemethod(_xapian.WritableDatabase_add_spelling, None, WritableDatabase) WritableDatabase.remove_spelling = new_instancemethod(_xapian.WritableDatabase_remove_spelling, None, WritableDatabase) WritableDatabase.add_synonym = new_instancemethod(_xapian.WritableDatabase_add_synonym, None, WritableDatabase) WritableDatabase.remove_synonym = new_instancemethod(_xapian.WritableDatabase_remove_synonym, None, WritableDatabase) WritableDatabase.clear_synonyms = new_instancemethod(_xapian.WritableDatabase_clear_synonyms, None, WritableDatabase) WritableDatabase.set_metadata = new_instancemethod(_xapian.WritableDatabase_set_metadata, None, WritableDatabase) WritableDatabase.__str__ = new_instancemethod(_xapian.WritableDatabase___str__, None, WritableDatabase) WritableDatabase.get_description = new_instancemethod(_xapian.WritableDatabase_get_description, None, WritableDatabase) WritableDatabase_swigregister = _xapian.WritableDatabase_swigregister WritableDatabase_swigregister(WritableDatabase) DB_CREATE_OR_OPEN = _xapian.DB_CREATE_OR_OPEN DB_CREATE = _xapian.DB_CREATE DB_CREATE_OR_OVERWRITE = _xapian.DB_CREATE_OR_OVERWRITE DB_OPEN = _xapian.DB_OPEN def open_stub(*args): ''' Construct a Database object for a stub database file. XAPIAN_VISIBILITY_DEFAULT Database Xapian::Auto::open_stub(const std::string &file) The stub database file contains serialised parameters for one or more databases. Parameters: ----------- file: pathname of the stub database file. ''' return _xapian.open_stub(*args) def inmemory_open(*args): ''' Construct a Database object for update access to an InMemory database. XAPIAN_VISIBILITY_DEFAULT WritableDatabase Xapian::InMemory::open() A new, empty database is created for each call. ''' return _xapian.inmemory_open(*args) class Query(object): ''' Class representing a query. Queries are represented as a tree of objects. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr OP_AND = _xapian.Query_OP_AND OP_OR = _xapian.Query_OP_OR OP_AND_NOT = _xapian.Query_OP_AND_NOT OP_XOR = _xapian.Query_OP_XOR OP_AND_MAYBE = _xapian.Query_OP_AND_MAYBE OP_FILTER = _xapian.Query_OP_FILTER OP_NEAR = _xapian.Query_OP_NEAR OP_PHRASE = _xapian.Query_OP_PHRASE OP_VALUE_RANGE = _xapian.Query_OP_VALUE_RANGE OP_SCALE_WEIGHT = _xapian.Query_OP_SCALE_WEIGHT OP_ELITE_SET = _xapian.Query_OP_ELITE_SET OP_VALUE_GE = _xapian.Query_OP_VALUE_GE OP_VALUE_LE = _xapian.Query_OP_VALUE_LE def __init__(self, *args): ''' Construct a value comparison query on a document value. Xapian::Query::Query(Query::op op_, Xapian::valueno valno, const std::string &value) This query matches those documents which have a value stored in the slot given by valno which compares, as specified by the operator, to value. Parameters: ----------- op_: The operator to use for the query. Currently, must be OP_VALUE_GE or OP_VALUE_LE. valno: The slot number to get the value from. value: The value to compare. ''' _xapian.Query_swiginit(self, _xapian.new_Query(*args)) __swig_destroy__ = _xapian.delete_Query def get_length(*args): ''' Get the length of the query, used by some ranking formulae. Xapian::termcount Xapian::Query::get_length() const This value is calculated automatically - if you want to override it you can pass a different value to Enquire::set_query(). ''' return _xapian.Query_get_length(*args) def get_terms_begin(*args): ''' Return a Xapian::TermIterator returning all the terms in the query, in order of termpos. TermIterator Xapian::Query::get_terms_begin() const If multiple terms have the same term position, their order is unspecified. Duplicates (same term and termpos) will be removed. ''' return _xapian.Query_get_terms_begin(*args) def get_terms_end(*args): ''' Return a Xapian::TermIterator to the end of the list of terms in the query. TermIterator Xapian::Query::get_terms_end() const ''' return _xapian.Query_get_terms_end(*args) def empty(*args): ''' Test if the query is empty (i.e. bool Xapian::Query::empty() const was constructed using the default ctor or with an empty iterator ctor). ''' return _xapian.Query_empty(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::Query::get_description() const ''' return _xapian.Query___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::Query::get_description() const ''' return _xapian.Query_get_description(*args) Query.get_length = new_instancemethod(_xapian.Query_get_length, None, Query) Query.get_terms_begin = new_instancemethod(_xapian.Query_get_terms_begin, None, Query) Query.get_terms_end = new_instancemethod(_xapian.Query_get_terms_end, None, Query) Query.empty = new_instancemethod(_xapian.Query_empty, None, Query) Query.__str__ = new_instancemethod(_xapian.Query___str__, None, Query) Query.get_description = new_instancemethod(_xapian.Query_get_description, None, Query) Query_swigregister = _xapian.Query_swigregister Query_swigregister(Query) quartz_open = _xapian.quartz_open def flint_open(*args): ''' Construct a Database object for update access to a Flint database. XAPIAN_VISIBILITY_DEFAULT WritableDatabase Xapian::Flint::open(const std::string &dir, int action, int block_size=8192) Parameters: ----------- dir: pathname of the directory containing the database. action: determines handling of existing/non-existing database: Xapian::DB_CREATE fail if database already exist, otherwise create new database. Xapian::DB_CREATE_OR_OPEN open existing database, or create new database if none exists. Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create new database if none exists. Xapian::DB_OPEN open existing database, failing if none exists. block_size: the Btree blocksize to use (in bytes), which must be a power of two between 2048 and 65536 (inclusive). The default (also used if an invalid value if passed) is 8192 bytes. This parameter is ignored when opening an existing database. ''' return _xapian.flint_open(*args) def remote_open(*args): """ Construct a Database object for read-only access to a remote database accessed via a program. XAPIAN_VISIBILITY_DEFAULT Database Xapian::Remote::open(const std::string &program, const std::string &args, Xapian::timeout timeout=10000) Access to the remote database is done by running an external program and communicating with it on stdin/stdout. Parameters: ----------- program: the external program to run. args: space-separated list of arguments to pass to program. timeout: timeout in milliseconds. If this timeout is exceeded for any individual operation on the remote database then Xapian::NetworkTimeoutError is thrown. A timeout of 0 means don't timeout. (Default is 10000ms, which is 10 seconds). """ return _xapian.remote_open(*args) def remote_open_writable(*args): """ Construct a WritableDatabase object for update access to a remote database accessed via a program. XAPIAN_VISIBILITY_DEFAULT WritableDatabase Xapian::Remote::open_writable(const std::string &program, const std::string &args, Xapian::timeout timeout=0) Access to the remote database is done by running an external program and communicating with it on stdin/stdout. Parameters: ----------- program: the external program to run. args: space-separated list of arguments to pass to program. timeout: timeout in milliseconds. If this timeout is exceeded for any individual operation on the remote database then Xapian::NetworkTimeoutError is thrown. (Default is 0, which means don't timeout). """ return _xapian.remote_open_writable(*args) class Stopper(object): ''' Base class for stop-word decision functor. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_Stopper def __str__(*args): ''' Return a string describing this object. virtual std::string Xapian::Stopper::get_description() const ''' return _xapian.Stopper___str__(*args) def get_description(*args): ''' Return a string describing this object. virtual std::string Xapian::Stopper::get_description() const ''' return _xapian.Stopper_get_description(*args) def __init__(self, *args): if self.__class__ == Stopper: args = (None,) + args else: args = (self,) + args _xapian.Stopper_swiginit(self, _xapian.new_Stopper(*args)) def __disown__(self): self.this.disown() _xapian.disown_Stopper(self) return weakref_proxy(self) Stopper.__call__ = new_instancemethod(_xapian.Stopper___call__, None, Stopper) Stopper.__str__ = new_instancemethod(_xapian.Stopper___str__, None, Stopper) Stopper.get_description = new_instancemethod(_xapian.Stopper_get_description, None, Stopper) Stopper_swigregister = _xapian.Stopper_swigregister Stopper_swigregister(Stopper) class SimpleStopper(Stopper): ''' Simple implementation of Stopper class - this will suit most users. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Initialise from a pair of iterators. Xapian::SimpleStopper::SimpleStopper(Iterator begin, Iterator end) ''' _xapian.SimpleStopper_swiginit(self, _xapian.new_SimpleStopper(*args)) def add(*args): ''' Add a single stop word. void Xapian::SimpleStopper::add(const std::string &word) ''' return _xapian.SimpleStopper_add(*args) __swig_destroy__ = _xapian.delete_SimpleStopper SimpleStopper.add = new_instancemethod(_xapian.SimpleStopper_add, None, SimpleStopper) SimpleStopper_swigregister = _xapian.SimpleStopper_swigregister SimpleStopper_swigregister(SimpleStopper) class ValueRangeProcessor(object): ''' Base class for value range processors. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_ValueRangeProcessor def __init__(self, *args): if self.__class__ == ValueRangeProcessor: args = (None,) + args else: args = (self,) + args _xapian.ValueRangeProcessor_swiginit(self, _xapian.new_ValueRangeProcessor(*args)) def __disown__(self): self.this.disown() _xapian.disown_ValueRangeProcessor(self) return weakref_proxy(self) ValueRangeProcessor.__call__ = new_instancemethod(_xapian.ValueRangeProcessor___call__, None, ValueRangeProcessor) ValueRangeProcessor.__call = new_instancemethod(_xapian.ValueRangeProcessor___call, None, ValueRangeProcessor) ValueRangeProcessor_swigregister = _xapian.ValueRangeProcessor_swigregister ValueRangeProcessor_swigregister(ValueRangeProcessor) class StringValueRangeProcessor(ValueRangeProcessor): ''' Handle a string range. The end points can be any strings. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Constructor. Xapian::StringValueRangeProcessor::StringValueRangeProcessor(Xapian::v alueno valno_) Parameters: ----------- valno_: The value number to return from operator(). ''' _xapian.StringValueRangeProcessor_swiginit(self, _xapian.new_StringValueRangeProcessor(*args)) __swig_destroy__ = _xapian.delete_StringValueRangeProcessor StringValueRangeProcessor_swigregister = _xapian.StringValueRangeProcessor_swigregister StringValueRangeProcessor_swigregister(StringValueRangeProcessor) class DateValueRangeProcessor(ValueRangeProcessor): ''' Handle a date range. Begin and end must be dates in a recognised format. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Constructor. Xapian::DateValueRangeProcessor::DateValueRangeProcessor(Xapian::value no valno_, bool prefer_mdy_=false, int epoch_year_=1970) Parameters: ----------- valno_: The value number to return from operator(). prefer_mdy_: Should ambiguous dates be interpreted as month/day/year rather than day/month/year? (default: false) epoch_year_: Year to use as the epoch for dates with 2 digit years (default: 1970, so 1/1/69 is 2069 while 1/1/70 is 1970). ''' _xapian.DateValueRangeProcessor_swiginit(self, _xapian.new_DateValueRangeProcessor(*args)) __swig_destroy__ = _xapian.delete_DateValueRangeProcessor DateValueRangeProcessor_swigregister = _xapian.DateValueRangeProcessor_swigregister DateValueRangeProcessor_swigregister(DateValueRangeProcessor) class NumberValueRangeProcessor(ValueRangeProcessor): thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): _xapian.NumberValueRangeProcessor_swiginit(self, _xapian.new_NumberValueRangeProcessor(*args)) __swig_destroy__ = _xapian.delete_NumberValueRangeProcessor NumberValueRangeProcessor_swigregister = _xapian.NumberValueRangeProcessor_swigregister NumberValueRangeProcessor_swigregister(NumberValueRangeProcessor) class QueryParser(object): ''' Build a Xapian::Query object from a user query string. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr FLAG_BOOLEAN = _xapian.QueryParser_FLAG_BOOLEAN FLAG_PHRASE = _xapian.QueryParser_FLAG_PHRASE FLAG_LOVEHATE = _xapian.QueryParser_FLAG_LOVEHATE FLAG_BOOLEAN_ANY_CASE = _xapian.QueryParser_FLAG_BOOLEAN_ANY_CASE FLAG_WILDCARD = _xapian.QueryParser_FLAG_WILDCARD FLAG_PURE_NOT = _xapian.QueryParser_FLAG_PURE_NOT FLAG_PARTIAL = _xapian.QueryParser_FLAG_PARTIAL FLAG_SPELLING_CORRECTION = _xapian.QueryParser_FLAG_SPELLING_CORRECTION FLAG_SYNONYM = _xapian.QueryParser_FLAG_SYNONYM FLAG_AUTO_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_SYNONYMS FLAG_AUTO_MULTIWORD_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_MULTIWORD_SYNONYMS STEM_NONE = _xapian.QueryParser_STEM_NONE STEM_SOME = _xapian.QueryParser_STEM_SOME STEM_ALL = _xapian.QueryParser_STEM_ALL def __init__(self, *args): ''' Default constructor. Xapian::QueryParser::QueryParser() ''' _xapian.QueryParser_swiginit(self, _xapian.new_QueryParser(*args)) __swig_destroy__ = _xapian.delete_QueryParser def set_stemmer(*args): ''' Set the stemmer. void Xapian::QueryParser::set_stemmer(const Xapian::Stem &stemmer) This sets the stemming algorithm which will be used by the query parser. Note that the stemming algorithm will only be used according to the stemming strategy set by set_stemming_strategy(), which defaults to STEM_NONE. Therefore, to use a stemming algorithm, you will also need to call set_stemming_strategy() with a value other than STEM_NONE. ''' return _xapian.QueryParser_set_stemmer(*args) def set_stemming_strategy(*args): ''' Set the stemming strategy. void Xapian::QueryParser::set_stemming_strategy(stem_strategy strategy) This controls how the query parser will apply the stemming algorithm. The default value is STEM_NONE. The possible values are: STEM_NONE: Don\'t perform any stemming. STEM_SOME: Search for stemmed forms of terms except for those which start with a capital letter, or are followed by certain characters (currently: (/@<>=*[{" ), or are used with operators which need positional information. Stemmed terms are prefixed with \'Z\'. STEM_ALL: Search for stemmed forms of all words (note: no \'Z\' prefix is added). Note that the stemming algorithm is only applied to words in probabilistic fields - boolean filter terms are never stemmed. ''' return _xapian.QueryParser_set_stemming_strategy(*args) def set_stopper(*args): ''' Set the stopper. void Xapian::QueryParser::set_stopper(const Stopper *stop=NULL) ''' return _xapian.QueryParser_set_stopper(*args) def set_default_op(*args): ''' Set the default boolean operator. void Xapian::QueryParser::set_default_op(Query::op default_op) ''' return _xapian.QueryParser_set_default_op(*args) def get_default_op(*args): ''' Get the default boolean operator. Query::op Xapian::QueryParser::get_default_op() const ''' return _xapian.QueryParser_get_default_op(*args) def set_database(*args): ''' Specify the database being searched. void Xapian::QueryParser::set_database(const Database &db) ''' return _xapian.QueryParser_set_database(*args) def parse_query(*args): ''' Parse a query. Query Xapian::QueryParser::parse_query(const std::string &query_string, unsigned flags=FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE, const std::string &default_prefix="") Parameters: ----------- query_string: A free-text query as entered by a user flags: Zero or more Query::feature_flag specifying what features the QueryParser should support. Combine multiple values with bitwise-or (|). default_prefix: The default term prefix to use (default none). For example, you can pass "A" when parsing an "Author" field. ''' return _xapian.QueryParser_parse_query(*args) def add_prefix(*args): ''' Add a probabilistic term prefix. void Xapian::QueryParser::add_prefix(const std::string &field, const std::string &prefix) For example: This allows the user to search for author:Orwell which will be converted to a search for the term "Aorwell". Multiple fields can be mapped to the same prefix. For example, you can make title: and subject: aliases for each other. As of 1.0.4, you can call this method multiple times with the same value of field to allow a single field to be mapped to multiple prefixes. Multiple terms being generated for such a field, and combined with Xapian::Query::OP_OR. If any prefixes are specified for the empty field name (i.e. you call this method with an empty string as the first parameter) these prefixes will be used as the default prefix. If you do this and also specify the default_prefix parameter to parse_query(), then the default_prefix parameter will override. If you call add_prefix() and add_boolean_prefix() for the same value of field, a Xapian::InvalidOperationError exception will be thrown. In 1.0.3 and earlier, subsequent calls to this method with the same value of field had no effect. Parameters: ----------- field: The user visible field name prefix: The term prefix to map this to ''' return _xapian.QueryParser_add_prefix(*args) def add_boolean_prefix(*args): ''' Add a boolean term prefix allowing the user to restrict a search with a boolean filter specified in the free text query. void Xapian::QueryParser::add_boolean_prefix(const std::string &field, const std::string &prefix) For example: This allows the user to restrict a search with site:xapian.org which will be converted to Hxapian.org combined with any probabilistic query with Xapian::Query::OP_FILTER. If multiple boolean filters are specified in a query for the same prefix, they will be combined with the Xapian::Query::OP_OR operator. Then, if there are boolean filters for different prefixes, they will be combined with the Xapian::Query::OP_AND operator. Multiple fields can be mapped to the same prefix (so for example you can make site: and domain: aliases for each other). Instances of fields with different aliases but the same prefix will still be combined with the OR operator. For example, if "site" and "domain" map to "H", but author maps to "A", a search for "site:foo domain:bar author:Fred" will map to "(Hfoo OR Hbar) AND Afred". As of 1.0.4, you can call this method multiple times with the same value of field to allow a single field to be mapped to multiple prefixes. Multiple terms being generated for such a field, and combined with Xapian::Query::OP_OR. Calling this method with an empty string for field will cause a Xapian::InvalidArgumentError. If you call add_prefix() and add_boolean_prefix() for the same value of field, a Xapian::InvalidOperationError exception will be thrown. In 1.0.3 and earlier, subsequent calls to this method with the same value of field had no effect. Parameters: ----------- field: The user visible field name prefix: The term prefix to map this to ''' return _xapian.QueryParser_add_boolean_prefix(*args) def stoplist_begin(*args): ''' Iterate over terms omitted from the query as stopwords. TermIterator Xapian::QueryParser::stoplist_begin() const ''' return _xapian.QueryParser_stoplist_begin(*args) def stoplist_end(*args): '''TermIterator Xapian::QueryParser::stoplist_end() const ''' return _xapian.QueryParser_stoplist_end(*args) def unstem_begin(*args): ''' Iterate over unstemmed forms of the given (stemmed) term used in the query. TermIterator Xapian::QueryParser::unstem_begin(const std::string &term) const ''' return _xapian.QueryParser_unstem_begin(*args) def unstem_end(*args): ''' TermIterator Xapian::QueryParser::unstem_end(const std::string &) const ''' return _xapian.QueryParser_unstem_end(*args) def add_valuerangeprocessor(*args): ''' Register a ValueRangeProcessor. void Xapian::QueryParser::add_valuerangeprocessor(Xapian::ValueRangePr ocessor *vrproc) ''' return _xapian.QueryParser_add_valuerangeprocessor(*args) def get_corrected_query_string(*args): ''' Get the spelling-corrected query string. std::string Xapian::QueryParser::get_corrected_query_string() const This will only be set if FLAG_SPELLING_CORRECTION is specified when QueryParser::parse_query() was last called. If there were no corrections, an empty string is returned. ''' return _xapian.QueryParser_get_corrected_query_string(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::QueryParser::get_description() const ''' return _xapian.QueryParser___str__(*args) def get_description(*args): ''' Return a string describing this object. std::string Xapian::QueryParser::get_description() const ''' return _xapian.QueryParser_get_description(*args) QueryParser.set_stemmer = new_instancemethod(_xapian.QueryParser_set_stemmer, None, QueryParser) QueryParser.set_stemming_strategy = new_instancemethod(_xapian.QueryParser_set_stemming_strategy, None, QueryParser) QueryParser.set_stopper = new_instancemethod(_xapian.QueryParser_set_stopper, None, QueryParser) QueryParser.set_default_op = new_instancemethod(_xapian.QueryParser_set_default_op, None, QueryParser) QueryParser.get_default_op = new_instancemethod(_xapian.QueryParser_get_default_op, None, QueryParser) QueryParser.set_database = new_instancemethod(_xapian.QueryParser_set_database, None, QueryParser) QueryParser.parse_query = new_instancemethod(_xapian.QueryParser_parse_query, None, QueryParser) QueryParser.add_prefix = new_instancemethod(_xapian.QueryParser_add_prefix, None, QueryParser) QueryParser.add_boolean_prefix = new_instancemethod(_xapian.QueryParser_add_boolean_prefix, None, QueryParser) QueryParser.stoplist_begin = new_instancemethod(_xapian.QueryParser_stoplist_begin, None, QueryParser) QueryParser.stoplist_end = new_instancemethod(_xapian.QueryParser_stoplist_end, None, QueryParser) QueryParser.unstem_begin = new_instancemethod(_xapian.QueryParser_unstem_begin, None, QueryParser) QueryParser.unstem_end = new_instancemethod(_xapian.QueryParser_unstem_end, None, QueryParser) QueryParser.add_valuerangeprocessor = new_instancemethod(_xapian.QueryParser_add_valuerangeprocessor, None, QueryParser) QueryParser.get_corrected_query_string = new_instancemethod(_xapian.QueryParser_get_corrected_query_string, None, QueryParser) QueryParser.__str__ = new_instancemethod(_xapian.QueryParser___str__, None, QueryParser) QueryParser.get_description = new_instancemethod(_xapian.QueryParser_get_description, None, QueryParser) QueryParser_swigregister = _xapian.QueryParser_swigregister QueryParser_swigregister(QueryParser) sortable_serialise = _xapian.sortable_serialise sortable_unserialise = _xapian.sortable_unserialise class Stem(object): ''' Class representing a stemming algorithm. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): """ Construct a Xapian::Stem object for a particular language. Xapian::Stem::Stem(const std::string &language) Parameters: ----------- language: Either the English name for the language or the two letter ISO639 code. The following language names are understood (aliases follow the name): none - don't stem terms danish (da) dutch (nl) english (en) - Martin Porter's 2002 revision of his stemmer english_lovins (lovins) - Lovin's stemmer english_porter (porter) - Porter's stemmer as described in his 1980 paper finnish (fi) french (fr) german (de) italian (it) norwegian (no) portuguese (pt) russian (ru) spanish (es) swedish (sv) Parameters: ----------- Xapian::InvalidArgumentError: is thrown if language isn't recognised. """ _xapian.Stem_swiginit(self, _xapian.new_Stem(*args)) __swig_destroy__ = _xapian.delete_Stem def __str__(*args): ''' Return a string describing this object. std::string Xapian::Stem::get_description() const ''' return _xapian.Stem___str__(*args) get_available_languages = staticmethod(_xapian.Stem_get_available_languages) def get_description(*args): ''' Return a string describing this object. std::string Xapian::Stem::get_description() const ''' return _xapian.Stem_get_description(*args) Stem.__call__ = new_instancemethod(_xapian.Stem___call__, None, Stem) Stem.__str__ = new_instancemethod(_xapian.Stem___str__, None, Stem) Stem.get_description = new_instancemethod(_xapian.Stem_get_description, None, Stem) Stem_swigregister = _xapian.Stem_swigregister Stem_swigregister(Stem) Stem_get_available_languages = _xapian.Stem_get_available_languages class TermGenerator(object): ''' Parses a piece of text and generate terms. This module takes a piece of text and parses it to produce words which are then used to generate suitable terms for indexing. The terms generated are suitable for use with Query objects produced by the QueryParser class. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Default constructor. Xapian::TermGenerator::TermGenerator() ''' _xapian.TermGenerator_swiginit(self, _xapian.new_TermGenerator(*args)) __swig_destroy__ = _xapian.delete_TermGenerator def set_stemmer(*args): ''' Set the Xapian::Stem object to be used for generating stemmed terms. void Xapian::TermGenerator::set_stemmer(const Xapian::Stem &stemmer) ''' return _xapian.TermGenerator_set_stemmer(*args) def set_stopper(*args): ''' Set the Xapian::Stopper object to be used for identifying stopwords. void Xapian::TermGenerator::set_stopper(const Xapian::Stopper *stop=NULL) ''' return _xapian.TermGenerator_set_stopper(*args) def set_document(*args): ''' Set the current document. void Xapian::TermGenerator::set_document(const Xapian::Document &doc) ''' return _xapian.TermGenerator_set_document(*args) def get_document(*args): ''' Get the current document. const Xapian::Document& Xapian::TermGenerator::get_document() const ''' return _xapian.TermGenerator_get_document(*args) def set_database(*args): ''' Set the database to index spelling data to. void Xapian::TermGenerator::set_database(const Xapian::WritableDatabase &db) ''' return _xapian.TermGenerator_set_database(*args) FLAG_SPELLING = _xapian.TermGenerator_FLAG_SPELLING def set_flags(*args): ''' Set flags. flags Xapian::TermGenerator::set_flags(flags toggle, flags mask=flags(0)) The new value of flags is: (flags & mask) ^ toggle To just set the flags, pass the new flags in toggle and the default value for mask. Parameters: ----------- toggle: Flags to XOR. mask: Flags to AND with first. The old flags setting. ''' return _xapian.TermGenerator_set_flags(*args) def index_text(*args): ''' Index some text in a std::string. void Xapian::TermGenerator::index_text(const std::string &text, Xapian::termcount weight=1, const std::string &prefix="") Parameters: ----------- weight: The wdf increment (default 1). prefix: The term prefix to use (default is no prefix). ''' return _xapian.TermGenerator_index_text(*args) def index_text_without_positions(*args): ''' Index some text in a std::string without positional information. void Xapian::TermGenerator::index_text_without_positions(const std::string &text, Xapian::termcount weight=1, const std::string &prefix="") Just like index_text, but no positional information is generated. This means that the database will be significantly smaller, but that phrase searching and NEAR won\'t be supported. ''' return _xapian.TermGenerator_index_text_without_positions(*args) def increase_termpos(*args): ''' Increase the termpos used by index_text by delta. void Xapian::TermGenerator::increase_termpos(Xapian::termcount delta=100) This can be used to prevent phrase searches from spanning two unconnected blocks of text (e.g. the title and body text). ''' return _xapian.TermGenerator_increase_termpos(*args) def get_termpos(*args): ''' Get the current term position. Xapian::termcount Xapian::TermGenerator::get_termpos() const ''' return _xapian.TermGenerator_get_termpos(*args) def set_termpos(*args): ''' Set the current term position. void Xapian::TermGenerator::set_termpos(Xapian::termcount termpos) ''' return _xapian.TermGenerator_set_termpos(*args) def __str__(*args): ''' Return a string describing this object. std::string Xapian::TermGenerator::get_description() const ''' return _xapian.TermGenerator___str__(*args) TermGenerator.set_stemmer = new_instancemethod(_xapian.TermGenerator_set_stemmer, None, TermGenerator) TermGenerator.set_stopper = new_instancemethod(_xapian.TermGenerator_set_stopper, None, TermGenerator) TermGenerator.set_document = new_instancemethod(_xapian.TermGenerator_set_document, None, TermGenerator) TermGenerator.get_document = new_instancemethod(_xapian.TermGenerator_get_document, None, TermGenerator) TermGenerator.set_database = new_instancemethod(_xapian.TermGenerator_set_database, None, TermGenerator) TermGenerator.set_flags = new_instancemethod(_xapian.TermGenerator_set_flags, None, TermGenerator) TermGenerator.index_text = new_instancemethod(_xapian.TermGenerator_index_text, None, TermGenerator) TermGenerator.index_text_without_positions = new_instancemethod(_xapian.TermGenerator_index_text_without_positions, None, TermGenerator) TermGenerator.increase_termpos = new_instancemethod(_xapian.TermGenerator_increase_termpos, None, TermGenerator) TermGenerator.get_termpos = new_instancemethod(_xapian.TermGenerator_get_termpos, None, TermGenerator) TermGenerator.set_termpos = new_instancemethod(_xapian.TermGenerator_set_termpos, None, TermGenerator) TermGenerator.__str__ = new_instancemethod(_xapian.TermGenerator___str__, None, TermGenerator) TermGenerator_swigregister = _xapian.TermGenerator_swigregister TermGenerator_swigregister(TermGenerator) class Sorter(object): ''' Virtual base class for sorter functor. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_Sorter def __init__(self, *args): if self.__class__ == Sorter: args = (None,) + args else: args = (self,) + args _xapian.Sorter_swiginit(self, _xapian.new_Sorter(*args)) def __disown__(self): self.this.disown() _xapian.disown_Sorter(self) return weakref_proxy(self) Sorter.__call__ = new_instancemethod(_xapian.Sorter___call__, None, Sorter) Sorter_swigregister = _xapian.Sorter_swigregister Sorter_swigregister(Sorter) class MultiValueSorter(Sorter): ''' Sorter subclass which sorts by a several values. Results are ordered by the first value. In the event of a tie, the second is used. If this is the same for both, the third is used, and so on. ''' thisown = _swig_property((lambda x: x.this.own()), (lambda x, v: x.this.own(v)), doc = 'The membership flag') __repr__ = _swig_repr def __init__(self, *args): ''' Xapian::MultiValueSorter::MultiValueSorter(Iterator begin, Iterator end) ''' _xapian.MultiValueSorter_swiginit(self, _xapian.new_MultiValueSorter(*args)) def add(*args): ''' void Xapian::MultiValueSorter::add(Xapian::valueno valno, bool forward=true) ''' return _xapian.MultiValueSorter_add(*args) __swig_destroy__ = _xapian.delete_MultiValueSorter MultiValueSorter.add = new_instancemethod(_xapian.MultiValueSorter_add, None, MultiValueSorter) MultiValueSorter_swigregister = _xapian.MultiValueSorter_swigregister MultiValueSorter_swigregister(MultiValueSorter) __docformat__ = 'restructuredtext en' class _SequenceMixIn(object): '''Simple mixin class which provides a sequence API to a class. This is used to support the legacy API to iterators used for releases of Xapian earlier than 1.0. It will be removed once this legacy API is removed in release 1.1. ''' __slots__ = ('_sequence_items',) def __init__(self, *args): """Initialise the sequence. *args holds the list of properties or property names to be returned, in the order they are returned by the sequence API. If an item in the list is a string, it is considered to be a property name; otherwise, it is considered to be a property value, and is returned without doing an attribute lookup. (Yes, this is a nasty hack. No, I don't care, because this is only a temporary piece of internal code.) """ self._sequence_items = args def __len__(self): """Get the length of the sequence. Doesn't evaluate any of the lazily evaluated properties. """ return len(self._sequence_items) def _get_single_item(self, index): '''Get a single item. Used by __getitem__ to get individual items. ''' if not isinstance(index, basestring): return index return getattr(self, index) def __getitem__(self, key): '''Get an item, or a slice of items, from the sequence. If any of the items are lazily evaluated properties, they will be evaluated here. ''' return self._get_single_item(self._sequence_items[key]) def __iter__(self): '''Make an iterator for over the sequence. This simply copies the items into a list, and returns an iterator over it. Any lazily evaluated properties will be evaluated here. ''' return iter(self[:]) class MSetItem(_SequenceMixIn): '''An item returned from iteration of the MSet. The item supports access to the following attributes and properties: - `docid`: The Xapian document ID corresponding to this MSet item. - `weight`: The weight corresponding to this MSet item. - `rank`: The rank of this MSet item. The rank is the position in the total set of matching documents of this item. The highest document is given a rank of 0. If the MSet did not start at the highest matching document, because a non-zero \'start\' parameter was supplied to get_mset(), the first document in the MSet will have a rank greater than 0 (in fact, it will be equal to the value of \'start\' supplied to get_mset()). - `percent`: The percentage score assigned to this MSet item. - `document`: The document for this MSet item. This can be used to access the document data, or any other information stored in the document (such as term lists). It is lazily evaluated. - `collapse_key`: The value of the key which was used for collapsing. - `collapse_count`: An estimate of the number of documents that have been collapsed into this one. The collapse count estimate will always be less than or equal to the actual number of other documents satisfying the match criteria with the same collapse key as this document. If may be 0 even though there are other documents with the same collapse key which satisfying the match criteria. However if this method returns non-zero, there definitely are other such documents. So this method may be used to inform the user that there are "at least N other matches in this group", or to control whether to offer a "show other documents in this group" feature (but note that it may not offer it in every case where it would show other documents). ''' __slots__ = ('_mset', '_firstitem', 'docid', 'weight', 'rank', 'percent', 'collapse_key', 'collapse_count', '_document') def __init__(self, iter, mset): self._mset = mset self._firstitem = self._mset.get_firstitem() self.docid = iter.get_docid() self.weight = iter.get_weight() self.rank = iter.get_rank() self.percent = iter.get_percent() self.collapse_key = iter.get_collapse_key() self.collapse_count = iter.get_collapse_count() self._document = None _SequenceMixIn.__init__(self, 'docid', 'weight', 'rank', 'percent', 'document') def _get_document(self): if self._document is None: self._document = self._mset._get_hit_internal(self.rank - self._firstitem).get_document() return self._document def get_docid(self): '''Deprecated method: use the `docid` property instead.''' return self.docid def get_weight(self): '''Deprecated method: use the `weight` property instead.''' return self.weight def get_rank(self): '''Deprecated method: use the `rank` property instead.''' return self.rank def get_percent(self): '''Deprecated method: use the `percent` property instead.''' return self.percent def get_collapse_key(self): '''Deprecated method: use the `collapse_key` property instead.''' return self.collapse_key def get_collapse_count(self): '''Deprecated method: use the `collapse_count` property instead.''' return self.collapse_count def get_document(self): '''Deprecated method: use the `document` property instead.''' return self.document document = property(_get_document, doc = 'The document object corresponding to this MSet item.') class MSetIter(object): '''An iterator over the items in an MSet. The iterator will return MSetItem objects, which will be evaluated lazily where appropriate. ''' __slots__ = ('_iter', '_end', '_mset') def __init__(self, mset): self._iter = mset.begin() self._end = mset.end() self._mset = mset def __iter__(self): return self def next(self): if self._iter == self._end: raise StopIteration else: r = MSetItem(self._iter, self._mset) self._iter.next() return r def _mset_gen_iter(self): '''Return an iterator over the MSet. The iterator will return MSetItem objects, which will be evaluated lazily where appropriate. ''' return MSetIter(self) MSet.__iter__ = _mset_gen_iter MSet.__len__ = MSet.size MSet._get_hit_internal = MSet.get_hit def _mset_getitem(self, index): '''Get an item from the MSet. The supplied index is relative to the start of the MSet, not the absolute rank of the item. Returns an MSetItem. ''' if index < 0: index += len(self) if index < 0 or index >= len(self): raise IndexError('Mset index out of range') return MSetItem(self._get_hit_internal(index), self) MSet.__getitem__ = _mset_getitem MSet.get_hit = _mset_getitem def _mset_contains(self, index): '''Check if the Mset contains an item at the given index The supplied index is relative to the start of the MSet, not the absolute rank of the item. ''' if key >= 0: pass return key < len(self) MSet.__contains__ = _mset_contains class ESetItem(_SequenceMixIn): '''An item returned from iteration of the ESet. The item supports access to the following attributes: - `term`: The term corresponding to this ESet item. - `weight`: The weight corresponding to this ESet item. ''' __slots__ = ('term', 'weight') def __init__(self, iter): self.term = iter.get_term() self.weight = iter.get_weight() _SequenceMixIn.__init__(self, 'term', 'weight') class ESetIter(object): '''An iterator over the items in an ESet. The iterator will return ESetItem objects. ''' __slots__ = ('_iter', '_end') def __init__(self, eset): self._iter = eset.begin() self._end = eset.end() def __iter__(self): return self def next(self): if self._iter == self._end: raise StopIteration else: r = ESetItem(self._iter) self._iter.next() return r def _eset_gen_iter(self): '''Return an iterator over the ESet. The iterator will return ESetItem objects. ''' return ESetIter(self) ESet.__iter__ = _eset_gen_iter ESet.__len__ = ESet.size class TermListItem(_SequenceMixIn): '''An item returned from iteration of a term list. The item supports access to the following attributes and properties: - `term`: The term corresponding to this TermListItem. - `wdf`: The within document frequency of this term. - `termfreq`: The number of documents in the collection which are indexed by the term - `positer`: An iterator over the positions which the term appears at in the document. This is only available until the iterator which returned this item next moves. ''' __slots__ = ('_iter', 'term', '_wdf', '_termfreq') def __init__(self, iter, term): self._iter = iter self.term = term self._wdf = None self._termfreq = None if iter._has_wdf == TermIter.EAGER: self._wdf = iter._iter.get_wdf() if iter._has_termfreq == TermIter.EAGER: self._termfreq = iter._iter.get_termfreq() sequence = [ 'term', 'wdf', 'termfreq', 'positer'] if iter._has_wdf == TermIter.INVALID: sequence[1] = 0 if iter._has_termfreq == TermIter.INVALID: sequence[2] = 0 if iter._has_positions == TermIter.INVALID: sequence[3] = PositionIter() _SequenceMixIn.__init__(self, *sequence) def _get_wdf(self): """Get the within-document-frequency of the current term. This will raise a InvalidOperationError exception if the iterator this item came from doesn't support within-document-frequencies. """ if self._wdf is None: if self._iter._has_wdf == TermIter.INVALID: raise InvalidOperationError('Iterator does not support wdfs') if self.term is not self._iter._lastterm: raise InvalidOperationError('Iterator has moved, and does not support random access') self._wdf = self._iter._iter.get_wdf() return self._wdf wdf = property(_get_wdf, doc = "The within-document-frequency of the current term (if meaningful).\n\n This will raise a InvalidOperationError exception if the iterator\n this item came from doesn't support within-document-frequencies.\n\n ") def _get_termfreq(self): """Get the term frequency. This is the number of documents in the collection which are indexed by the term. This will raise a InvalidOperationError exception if the iterator this item came from doesn't support term frequencies. """ if self._termfreq is None: if self._iter._has_termfreq == TermIter.INVALID: raise InvalidOperationError('Iterator does not support term frequencies') if self.term is not self._iter._lastterm: raise InvalidOperationError('Iterator has moved, and does not support random access') self._termfreq = self._iter._iter.get_termfreq() return self._termfreq termfreq = property(_get_termfreq, doc = "The term frequency of the current term (if meaningful).\n\n This is the number of documents in the collection which are indexed by the\n term.\n\n This will raise a InvalidOperationError exception if the iterator\n this item came from doesn't support term frequencies.\n\n ") def _get_positer(self): """Get a position list iterator. The iterator will return integers representing the positions that the term occurs at. This will raise a InvalidOperationError exception if the iterator this item came from doesn't support position lists, or if the iterator has moved on since the item was returned from it. """ if self._iter._has_positions == TermIter.INVALID: raise InvalidOperationError('Iterator does not support position lists') if self.term is not self._iter._lastterm: raise InvalidOperationError('Iterator has moved, and does not support random access') return PositionIter(self._iter._iter.positionlist_begin(), self._iter._iter.positionlist_end()) positer = property(_get_positer, doc = "A position iterator for the current term (if meaningful).\n\n The iterator will return integers representing the positions that the term\n occurs at.\n\n This will raise a InvalidOperationError exception if the iterator this item\n came from doesn't support position lists, or if the iterator has moved on\n since the item was returned from it.\n\n ") class TermIter(object): '''An iterator over a term list. The iterator will return TermListItem objects, which will be evaluated lazily where appropriate. ''' __slots__ = ('_iter', '_end', '_has_termfreq', '_has_wdf', '_has_positions', '_return_strings', '_lastterm', '_moved') INVALID = 0 LAZY = 1 EAGER = 2 def __init__(self, start, end, has_termfreq = INVALID, has_wdf = INVALID, has_positions = INVALID, return_strings = False): self._iter = start self._end = end self._has_termfreq = has_termfreq self._has_wdf = has_wdf self._has_positions = has_positions if not has_positions != TermIter.EAGER: raise AssertionError self._return_strings = return_strings self._lastterm = None self._moved = True def __iter__(self): return self def next(self): if not self._moved: self._iter.next() self._moved = True if self._iter == self._end: self._lastterm = None raise StopIteration else: self._lastterm = self._iter.get_term() self._moved = False if self._return_strings: return self._lastterm return TermListItem(self, self._lastterm) def skip_to(self, term): '''Skip the iterator forward. The iterator is advanced to the first term at or after the current position which is greater than or equal to the supplied term. If there are no such items, this will raise StopIteration. This returns the item which the iterator is moved to. The subsequent item will be returned the next time that next() is called (unless skip_to() is called again first). ''' if self._iter != self._end: self._iter.skip_to(term) if self._iter == self._end: self._lastterm = None self._moved = True raise StopIteration newterm = self._iter.get_term() if newterm != self._lastterm: self._lastterm = newterm self._moved = False if self._return_strings: return self._lastterm return TermListItem(self, self._lastterm) def _enquire_gen_iter(self, which): '''Get an iterator over the terms which match a given match set item. The match set item to consider is specified by the `which` parameter, which may be a document ID, or an MSetItem object. The iterator will return string objects. ''' if isinstance(which, MSetItem): which = which.docid return TermIter(self.get_matching_terms_begin(which), self.get_matching_terms_end(which), return_strings = True) Enquire.matching_terms = _enquire_gen_iter Enquire.get_matching_terms = _enquire_gen_iter def _query_gen_iter(self): '''Get an iterator over the terms in a query. The iterator will return string objects. ''' return TermIter(self.get_terms_begin(), self.get_terms_end(), return_strings = True) Query.__iter__ = _query_gen_iter def _database_gen_allterms_iter(self, prefix = None): '''Get an iterator over all the terms in the database. The iterator will return TermListItem objects, but these will not support access to wdf, or position information. Access to term frequency information is only available until the iterator has moved on. If prefix is supplied, only terms which start with that prefix will be returned. ''' if prefix is None: return TermIter(self.allterms_begin(), self.allterms_end(), has_termfreq = TermIter.LAZY) else: return TermIter(self.allterms_begin(prefix), self.allterms_end(prefix), has_termfreq = TermIter.LAZY) Database.__iter__ = _database_gen_allterms_iter Database.allterms = _database_gen_allterms_iter def _database_gen_termlist_iter(self, docid): '''Get an iterator over all the terms which index a given document ID. The iterator will return TermListItem objects. Access to term frequency and position information is only available until the iterator has moved on. ''' return TermIter(self.termlist_begin(docid), self.termlist_end(docid), has_termfreq = TermIter.LAZY, has_wdf = TermIter.EAGER, has_positions = TermIter.LAZY) Database.termlist = _database_gen_termlist_iter def _database_gen_spellings_iter(self): '''Get an iterator which returns all the spelling correction targets The iterator will return TermListItem objects. Only the term frequency is available; wdf and positions are not meaningful. ''' return TermIter(self.spellings_begin(), self.spellings_end(), has_termfreq = TermIter.EAGER, has_wdf = TermIter.INVALID, has_positions = TermIter.INVALID) Database.spellings = _database_gen_spellings_iter def _database_gen_synonyms_iter(self, term): '''Get an iterator which returns all the synonyms for a given term. The term to return synonyms for is specified by the `term` parameter. The iterator will return string objects. ''' return TermIter(self.synonyms_begin(term), self.synonyms_end(term), return_strings = True) Database.synonyms = _database_gen_synonyms_iter def _database_gen_synonym_keys_iter(self, prefix = ''): '''Get an iterator which returns all the terms which have synonyms. The iterator will return string objects. If `prefix` is non-empty, only terms with this prefix are returned. ''' return TermIter(self.synonym_keys_begin(prefix), self.synonym_keys_end(prefix), return_strings = True) Database.synonym_keys = _database_gen_synonym_keys_iter def _document_gen_termlist_iter(self): '''Get an iterator over all the terms in a document. The iterator will return TermListItem objects. Access to term frequency and position information is only available until the iterator has moved on. Note that term frequency information is only meaningful for a document retrieved from a database. If term frequency information is requested for a document which was freshly created, an InvalidOperationError will be raised. ''' return TermIter(self.termlist_begin(), self.termlist_end(), has_termfreq = TermIter.LAZY, has_wdf = TermIter.EAGER, has_positions = TermIter.LAZY) Document.__iter__ = _document_gen_termlist_iter Document.termlist = _document_gen_termlist_iter def _queryparser_gen_stoplist_iter(self): '''Get an iterator over all the stopped terms from the previous query. This returns an iterator over all the terms which were omitted from the previously parsed query due to being considered to be stopwords. Each instance of a word omitted from the query is represented in the returned list, in the order in which the The iterator will return string objects. ''' return TermIter(self.stoplist_begin(), self.stoplist_end(), return_strings = True) QueryParser.stoplist = _queryparser_gen_stoplist_iter def _queryparser_gen_unstemlist_iter(self, tname): '''Get an iterator over all the unstemmed forms of a stemmed term. This returns an iterator which returns all the unstemmed words which were stemmed to the stemmed form specifed by `tname` when parsing the previous query. Each instance of a word which stems to `tname` is returned by the iterator in the order in which the words appeared in the query - an individual unstemmed word may thus occur multiple times. The iterator will return string objects. ''' return TermIter(self.unstem_begin(tname), self.unstem_end(tname), return_strings = True) QueryParser.unstemlist = _queryparser_gen_unstemlist_iter class PostingItem(_SequenceMixIn): '''An item returned from iteration of a posting list. The item supports access to the following attributes and properties: - `docid`: The document ID corresponding to this PostingItem. - `doclength`: The length of the document corresponding to this PostingItem. - `wdf`: The within document frequency of the term which the posting list is for in the document corresponding to this PostingItem. - `positer`: An iterator over the positions which the term corresponing to this posting list occurs at in the document corresponding to this PostingItem. This is only available until the iterator which returned this item next moves. ''' __slots__ = ('_iter', 'docid', 'doclength', 'wdf') def __init__(self, iter): self._iter = iter self.docid = iter._iter.get_docid() self.doclength = iter._iter.get_doclength() self.wdf = iter._iter.get_wdf() sequence = [ 'docid', 'doclength', 'wdf', 'positer'] if not iter._has_positions: sequence[3] = PositionIter() _SequenceMixIn.__init__(self, *sequence) def _get_positer(self): """Get a position list iterator. The iterator will return integers representing the positions that the term occurs at in the document corresponding to this PostingItem. This will raise a InvalidOperationError exception if the iterator this item came from doesn't support position lists, or if the iterator has moved on since the item was returned from it. """ if not self._iter._has_positions: raise InvalidOperationError('Iterator does not support position lists') if self._iter._iter == self._iter._end or self.docid != self._iter._iter.get_docid(): raise InvalidOperationError('Iterator has moved, and does not support random access') return PositionIter(self._iter._iter.positionlist_begin(), self._iter._iter.positionlist_end()) positer = property(_get_positer, doc = "A position iterator for the current posting (if meaningful).\n\n The iterator will return integers representing the positions that the term\n occurs at.\n\n This will raise a InvalidOperationError exception if the iterator this item\n came from doesn't support position lists, or if the iterator has moved on\n since the item was returned from it.\n\n ") class PostingIter(object): '''An iterator over a posting list. The iterator will return PostingItem objects, which will be evaluated lazily where appropriate. ''' __slots__ = ('_iter', '_end', '_has_positions', '_moved') def __init__(self, start, end, has_positions = False): self._iter = start self._end = end self._has_positions = has_positions self._moved = True def __iter__(self): return self def next(self): if not self._moved: self._iter.next() self._moved = True if self._iter == self._end: raise StopIteration else: self._moved = False return PostingItem(self) def skip_to(self, docid): '''Skip the iterator forward. The iterator is advanced to the first document with a document ID which is greater than or equal to the supplied document ID. If there are no such items, this will raise StopIteration. This returns the item which the iterator is moved to. The subsequent item will be returned the next time that next() is called (unless skip_to() is called again first). ''' if self._iter != self._end: self._iter.skip_to(docid) if self._iter == self._end: self._moved = True raise StopIteration self._moved = False return PostingItem(self) def _database_gen_postlist_iter(self, tname): '''Get an iterator over the postings which are indexed by a given term. If `tname` is empty, an iterator over all the documents will be returned (this will contain one entry for each document, will always return a wdf of 1, and will not allow access to a position iterator). ''' if len(tname) != 0: return PostingIter(self.postlist_begin(tname), self.postlist_end(tname), has_positions = True) else: return PostingIter(self.postlist_begin(tname), self.postlist_end(tname)) Database.postlist = _database_gen_postlist_iter class PositionIter(object): '''An iterator over a position list. The iterator will return integers, in ascending order. ''' def __init__(self, start = 0, end = 0): self.iter = start self.end = end def __iter__(self): return self def next(self): if self.iter == self.end: raise StopIteration else: r = self.iter.get_termpos() self.iter.next() return r def _database_gen_positionlist_iter(self, docid, tname): '''Get an iterator over all the positions in a given document of a term. The iterator will return integers, in ascending order. ''' return PositionIter(self.positionlist_begin(docid, tname), self.positionlist_end(docid, tname)) Database.positionlist = _database_gen_positionlist_iter class ValueItem(_SequenceMixIn): '''An item returned from iteration of the values in a document. The item supports access to the following attributes: - `num`: The number of the value. - `value`: The contents of the value. ''' __slots__ = ('num', 'value') def __init__(self, num, value): self.num = num self.value = value _SequenceMixIn.__init__(self, 'num', 'value') class ValueIter(object): '''An iterator over all the values stored in a document. The iterator will return ValueItem objects, in ascending order of value number. ''' def __init__(self, start, end): self.iter = start self.end = end def __iter__(self): return self def next(self): if self.iter == self.end: raise StopIteration else: r = ValueItem(self.iter.get_valueno(), self.iter.get_value()) self.iter.next() return r def _document_gen_values_iter(self): '''Get an iterator over all the values stored in a document. The iterator will return ValueItem objects, in ascending order of value number. ''' return ValueIter(self.values_begin(), self.values_end()) Document.values = _document_gen_values_iter __all__ = [] for item in dir(): if item.startswith('_') and item.endswith('_swigregister') or item.endswith('Iterator'): continue __all__.append(item) __all__ = tuple(__all__) ValueRangeProcessor.__call__ = ValueRangeProcessor.__call